I’ve got several custom image sizes for my blog. One of these is setup as add_image_size( 'slide', 640, 290, true );
. These are used in a header slideshow.
My problem is I’ve upped the dimensions of this size after many of them were originally created, and many of the attached post images are too small to be cropped to these new values (i.e. not even 640px in the first place).
So when I call up images of this size, many of them are of the old dimensions (e.g. s:5:"slide";a:4:{s:4:"file";s:52:"6a00d8341c630a53ef011570180a91970b-800wi-300x290.jpg";s:5:"width";s:3:"300";s:6:"height";s:3:"290";}
. I can’t use images that are this small, but no correctly sized image are overwriting these, as per above. The desired behavior is that no image would be stored for size
slide instead of the old, small ones.
How can I delete these image entries in _wp_attachment_metadata? Do I do delete everything in the sizes
sub-array and regenerate everything?
Not from personal experience (I don’t use WP image management much), but I believe Regenerate Thumbnails plugin is usually recommended for rebuilding thumbnails.
As already mentioned, Regenerate Thumbnails plugin triggers the (re)generation of image sizes which are currently defined via add_image_size() or similar.
Here is a patch to modify Regenerate Thumbnails Version 2.2.0 so it will delete any previously generated image-sizes, including older outdated sizes before creating the new sizes.
http://wordpress.org/support/topic/how-to-delete-old-thumbnail-images
Important: Note that URLs to images are hard-coded in posts and pages. Removing old thumbnails could result in broken images if they are still used somewhere on your site. You have been warned…