WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 3 down vote accepted

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);
share|improve this answer
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 at 21:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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