Composer
composer require rwsite/wp-thumbnail-plugin
Вручную
On-demand thumbnail generation and caching for WordPress
Crop or resize local attachments and reuse the results from the filesystem cache.
Requirements • Installation • Settings • PHP templates • Companion plugin • RU version
mbstring. The header and Composer metadata still list PHP 7.4, but the runtime uses PHP 8 syntax, including union types.wp-content/cache/thumb/.composer require rwsite/wp-thumbnail-plugin
wp-content/plugins/wp-thumbnail-plugin/wp-thumbnail-plugin.php exists. For a Git-managed site, you can add the repository as a submodule at wp-content/plugins/wp-thumbnail-plugin instead.quality to override it per call.'format' => 'webp' for a single call. WebP requires support in the active image library. With neither a format override nor WebP enabled, output uses the source URL's extension. The processors list JPEG (jpg/jpeg), PNG, GIF and WebP (GD lists WebP only if its encoder is available).get_post_thumbnail() fallback, not to direct thumb_* calls. The external-host, upscaling and automatic cleanup fields do not enable remote fetching, control upscaling or schedule cache cleanup in the current generator.Call these helpers after WordPress init, for example in a theme template. Pass a local media attachment ID as the second argument (or use attach_id in the options). Use post_id to select a post's featured image. Although the signature accepts URLs, a bare URL does not provide the local file path required for generation; this API does not download remote images or search post content for a source.
$attachment_id = get_post_thumbnail_id();
if ($attachment_id) {
$size = ['width' => 480, 'height' => 320, 'crop' => true];
$url = thumb_src($size, $attachment_id); // URL, or '' if unavailable.
echo thumb_img($size + ['class' => 'post-cover', 'alt' => get_the_title()], $attachment_id);
echo thumb_a_img($size, $attachment_id); // Image linked to the original.
}
Choose one helper for the output you need. Use esc_url() if you insert the URL returned by thumb_src() into HTML. crop => false resizes without cropping. thumb_img() and thumb_a_img() return an empty string when generation fails; the linked variant can return just the image when no original URL is resolved. The kama_thumb_* names remain as compatibility wrappers. See the API reference for signatures.
Taxonomy Thumbnail assigns images to taxonomy terms and lets posts inherit a fallback cover from a term. WP Thumbnails generates image files at the requested dimensions; it does not manage those assignments. Use both if you need term-based covers and generated thumbnails.
See CHANGELOG.md.
GPL-2.0-or-later
Aleksei Tikhomirov (https://rwsite.ru)