I am trying to delay WordPress auto thumbnail generation for specific image size only i.e. 'medium'.

As I am using GD library to print Post Title on the image automatically, and it replaces the original image just after uploading.

But at the same time, WordPress creates other images i.e. 'medium' and 'thumbnail' from the original image which is without the Post title. So, I could not use 'medium' image as the featured image.

Note - I only wanted to delay the 'medium' $size image, not the 'large' or 'thumbnail'.

So, I have tried to unset the 'medium' image with intermediate_image_sizes_advanced filter and then used sleep(1); to delay the auto thumbnails generation for 'medium' image. Then I added a new image size but it doesn't work. Need help.

I also tried to recall the unset using __set() and __isset(), but no luck.

//Delay specific thumbnail generation 
function sk_delay_thumb_genration($sizes) {
    unset( $sizes['medium']);
    return $sizes;

    $myimgsizes = array(
        'medium-img' => __('Medium Img'),
        'width'      => 300,
        'height'     => 300,        

    return $myimgsizes;
add_filter('intermediate_image_sizes_advanced', 'sk_delay_thumb_genration' ); 

Your Answer

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

Browse other questions tagged or ask your own question.