By default, when you upload an image such as a png or jpeg to the media library, WordPress generates all the standard image sizes that may be used by a theme, such as ‘thumbnail’ and ‘post-thumbnail’. Including any custom sizes you may have added to your theme using add_theme_support( 'post-thumbnails' ), set_post_thumbnail_size( 250, 250, true );, add_image_size( 'small', 500, 500 );, etc.
But when you upload an image in pdf format, by default WordPress only generates the ‘thumbnail’, ‘medium’ and ‘large’ sizes — not all the other sizes your theme may use. Here’s a quick fix for that you can put into your theme’s functions.php:
// Note for PHP 7 or higher, uses return type declaration
add_filter(
'fallback_intermediate_image_sizes',
function ( array $fallback_sizes, array $metadata ) : array {
return array_merge( $fallback_sizes, array_keys( wp_get_registered_image_subsizes() ) );
},
10, 2 );
WordPress also has hardcoded behavior in wp-admin/includes/image.php to override whatever you have set the ‘crop’ parameter to for ‘thumbnail’ to false. This is a bug in my opinion because if your theme depends on images being cropped to specific dimensions or aspect ratio, this overrides it for no good reason I can think of. I don’t know of any workaround for this.
You must log in before being able to contribute a note or feedback.
By default, when you upload an image such as a png or jpeg to the media library, WordPress generates all the standard image sizes that may be used by a theme, such as ‘thumbnail’ and ‘post-thumbnail’. Including any custom sizes you may have added to your theme using
add_theme_support( 'post-thumbnails' )
,set_post_thumbnail_size( 250, 250, true );
,add_image_size( 'small', 500, 500 );
, etc.But when you upload an image in pdf format, by default WordPress only generates the ‘thumbnail’, ‘medium’ and ‘large’ sizes — not all the other sizes your theme may use. Here’s a quick fix for that you can put into your theme’s
functions.php
:WordPress also has hardcoded behavior in
wp-admin/includes/image.php
to override whatever you have set the ‘crop’ parameter to for ‘thumbnail’ tofalse
. This is a bug in my opinion because if your theme depends on images being cropped to specific dimensions or aspect ratio, this overrides it for no good reason I can think of. I don’t know of any workaround for this.