KDA Thumbnails creates resized, cached image thumbnails from the WordPress Media Library (or any local file) without touching your original uploads. Thumbnails are generated once, stored in a configurable cache folder, and served directly on subsequent requests. Both the generated thumbnails and any downloaded web fonts are kept outside the plugin folder, so the plugin is safe to publish to the WordPress.org repository.
The plugin works in two modes: zero-code (everything from the settings page) and developer mode (shortcodes, PHP functions, filters).
Zero-code mode (no programming required):
wp-content/uploads/kda-thumbnails/).sizes attribute.<img> tags in post content with optimized thumbnails.That is it. The plugin takes care of the rest: generating thumbnails on first request, caching them, invalidating when the source changes, and enforcing a cache size quota if configured.
Developer mode (shortcodes and PHP):
[kdath_thumbnail] shortcode in posts, pages, or widgets.the_content to process all content images automatically.kdath_thumbs_url) to store and retrieve thumbnail URLs.wp-content/uploads/..ttf/.otf path can be used instead.[kdath_thumbnail] and PHP helper functions for theme and plugin developers.kdath_get_thumbnail_srcset( $args, $widths ) + kdath_the_thumbnail_srcset() for responsive srcset.the_content filter).<img> tag can include srcset with wp-style width descriptors and an optional sizes attribute. Works for plugin shortcodes/PHP functions, content images, and native WordPress featured images.When a watermark is rendered the font is resolved in this order:
wp-content/uploads/kda-thumbnails-fonts/<family>.ttf and reused).The selected Google Font is downloaded on first use and cached, so the watermark always has a real font to render with (important for Imagick, which otherwise renders nothing when no font is configured). The “Status” panel on the settings page shows the resolved font and whether the Google Font has already been downloaded.
[kdath_thumbnail id="123" width="400" height="300" quality="90" crop="center" format="webp" alt="Photo"]
Shortcode parameters:
id — Media Library attachment ID (integer).src — alternative to id: local file path or URL inside wp-content/uploads/. Remote URLs are only supported when remote caching is enabled; otherwise use a Media Library ID or local path.width — target width in pixels (integer).height — target height in pixels (integer).quality — JPEG/WebP quality, 1-100 (default: 90 from settings).crop — crop mode: top, bottom, left, right, center (default: center).format — output format: jpg, png, webp (default: global “Output format” setting).alt — image alt text (string).class — extra CSS class(es) for the <img> tag (string).Shortcode return value: an <img> HTML tag with src, width, height, alt, class, and optional srcset/sizes. On error returns empty string for non-admins, or an HTML comment with the error message for admins.
All functions are available after the plugin is activated.
kdath_get_thumbnail( $args )
Returns the cached thumbnail URL (string) or WP_Error on failure.
Example:
$url = kdath_get_thumbnail( array( 'id' => 123, 'width' => 400, 'height' => 300 ) );
kdath_the_thumbnail( $args ) / kdath_the_thumbnail_src( $args )
Echoes the thumbnail URL directly. Same args as kdath_get_thumbnail().
Example:
kdath_the_thumbnail_src( array( 'id' => 123, 'width' => 400 ) );
kdath_get_thumbnail_img( $args, $attributes )
Returns a complete <img> tag. $attributes is an array of extra HTML attributes (class, loading, decoding, fetchpriority, style, etc.). When “Responsive srcset” is enabled in settings, srcset and sizes are added automatically unless explicitly passed in $attributes.
Example:
echo kdath_get_thumbnail_img(
array( 'id' => 123, 'width' => 400, 'height' => 300 ),
array( 'class' => 'my-custom-class', 'loading' => 'lazy' )
);
kdath_the_thumbnail_img( $args, $attributes )
Echoes the <img> tag. Useful inside theme templates.
Example:
kdath_the_thumbnail_img( array( 'src' => '/path/to/image.jpg', 'width' => 800, 'height' => 600, 'crop' => 'center' ), array( 'alt' => 'My photo' ) );
kdath_get_thumbnail_srcset( $args, $widths )
Returns a srcset string (e.g. "url1 300w, url2 768w, url3 1200w") or WP_Error. Generates one cached thumbnail per width.
Example:
$srcset = kdath_get_thumbnail_srcset( array( 'id' => 123 ), array( 300, 768, 1200 ) );
kdath_the_thumbnail_srcset( $args, $widths )
Echoes the srcset string.
Example:
kdath_the_thumbnail_srcset( array( 'id' => 123 ), array( 300, 768, 1200 ) );
kdath_get_thumbnail_url_from_meta( $post_id, $meta_key = '' )
Returns the thumbnail URL saved in the custom field configured in settings. Requires a Media Library attachment ID. If $meta_key is omitted, the globally configured field name is used.
Example:
echo kdath_get_thumbnail_url_from_meta( 123 );
kdath_the_thumbnail_url_from_meta( $post_id, $meta_key = '' )
Echoes the URL from the custom field.
Example:
echo kdath_the_thumbnail_url_from_meta( 123 );
KDATH_Thumbnail_Cache::clear_all()
Programmatically clear the entire cache. Useful after bulk imports or when you need to regenerate all thumbnails immediately.
Example:
KDATH_Thumbnail_Cache::clear_all();
Automatic content processing (no code required):
When the plugin is active, it automatically hooks into the_content and post_thumbnail_html. Images in post content that have one of the configured CSS classes (Settings в†’ “Classes for automatic caching”) are replaced with cached thumbnails. Featured images rendered by WordPress (including block themes like Twenty Twenty-Five) are also processed and can include srcset/sizes automatically.
If you prefer to apply this manually, use:
add_filter( 'the_content', function( $content ) {
return KDATH_Thumbnail_Content_Processor::process( $content );
} );
This replaces standard <img> tags in post content with optimized thumbnails. Useful when you cannot edit theme templates directly.
When “Custom field for thumbnail URL” (kdath_thumbs_url) is configured in Settings в†’ KDA Thumbnails, the plugin automatically saves the generated thumbnail URL into that post meta key for every Media Library attachment. This is useful if you want to access the URL via get_post_meta() without calling the plugin functions again.
Example:
update_post_meta( 123, 'kdath_thumbs_url', 'https://example.com/wp-content/uploads/kda-thumbnails/kdath_abc123_400x300.jpg' );
// Retrieve later:
$url = get_post_meta( 123, 'kdath_thumbs_url', true );
// Or via helper:
echo kdath_the_thumbnail_url_from_meta( 123 );
All settings are available under Settings в†’ KDA Thumbnails. No code is required.
General tab:
wp-content/uploads/. Default: kda-thumbnails.format parameter.quality parameter.Watermark tab:
.ttf or .otf font file.Responsive images tab:
srcset and sizes attributes automatically.sizes attribute value. Leave empty to omit.Cache management tab:
Debug & docs tab:
wp-content/uploads/kda-thumbnails/ by default (configurable via Settings в†’ KDA Thumbnails).wp-content/uploads/kda-thumbnails-fonts/.This plugin connects to the GitHub API (https://api.github.com) to list the contents of the google/fonts repository and locate the appropriate TrueType font files for the selected Google Font family. The font files are downloaded from GitHub’s raw content delivery network and cached locally under wp-content/uploads/kda-thumbnails-fonts/.
Data sent: The name of the selected Google Font family is included in the API URL path. No user-specific data is transmitted. Requests include a User-Agent header identifying the plugin.
Service provider: GitHub, Inc.
Terms of Service: https://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacy Policy: https://docs.github.com/site-policy/privacy-policies/github-privacy-statement