Filters the image sizes generated for non-image mime types.
Parameters
$fallback_sizes
string[]- An array of image size names.
$metadata
array- Current attachment metadata.
Source
$fallback_sizes = apply_filters( 'fallback_intermediate_image_sizes', $fallback_sizes, $metadata );
Changelog
Version | Description |
---|---|
4.7.0 | Introduced. |
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.