2

I have a custom image size at 200x150 that works fine in a plugin I'm working on. Uploading new files is no problem but when I edit an image, the default image sizes get regenerated but my custom size does not. Is there a way to force the regeneration programatically in a filter or something?

3

To regenerate custom image size when image is edited in image editor , You have to add following options in wp_options table using update_option function along with add_image_size.

Example :

$img_size_name = 'custom-size'; // The new image size name.
if ( function_exists( 'add_theme_support' ) )
add_image_size($img_size_name, 100, 100 , true);

update_option($img_size_name.'_size_w', 100);
update_option($img_size_name.'_size_h', 100);
update_option($img_size_name.'_crop', 1);
  • 1
    Thank you, that did it. It's weird that add_image_size doesn't do this by default. Sounds like the function needs to be expanded. – Manny Fleurmond Mar 8 '13 at 14:56
  • This may have worked for whatever version of WordPress the questions is referring. Recent versions of WordPress ( I'm thinking 3.9 on ) will auto-regenerate custom images and default images if the Apply to all images radio button is checked ( whenever editing the image ). The apply option will also only be available if the post type has a thumbnail size, so the niche cases where your post type doesn't have a thumbnail size - this option will not show up and you'll run into issues. – Howdy_McGee Feb 18 '16 at 21:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.