Unexpected behaviour when new size is larger than full image
Opened this issue · 4 comments
Suppose a site has post thumbnails set to 200x200; I change this to 600x600 and regenerate thumbnails (telling the plugin to skip correctly sized images).
If after doing so, I upload a new 400x400 image, the post-thumbnail size won't get created in the metadata (since it is too small), so when the theme calls the_post_thumbnail(), it will output the full 400x400 image.
However, if a 400x400 image was uploaded prior to regeneration, when the theme calls the_post_thumbnail, it will output the original 200x200 image.
This is because the plugin is skipping the thumbnail size ('thumbnail would be larger than original'), but leaving the old size in the metadata, rather than removing it.
I believe removing it would be the logical behaviour.
AFAIK, WP 5.3 and above will clear all metadata[sizes] on upload and on regenerate
No, this is nothing to do with the WP version (it would in fact be very bad if it cleared the metadata in general, since it's often important to have unregistered sizes).
This is a bug report for the Regenerate Thumbnails plugin. It adds the sizes back in after calling the core WordPress function:
As mentioned, adding these sizes back is a vital part of the plugin - for example, at the point you upload a Site Icon to WordPress, it adds some square sizes to the metadata unique to that image so that it doesn't need to register a size and have it generated for your entire Media library. If these weren't readded, Site Icons would break after using this plugin.
So that section of the code shouldn't be removed; unregistered sizes should be re-added, but registered sizes - which may not exist in the new metadata due to the fact the original image isn't large enough - shouldn't.