I have three custom sizes:

add_image_size( 'img-movil', 667, 667, true );
add_image_size( 'c200x200', 200, 200, true );
add_image_size( 'c400x400', 400, 400, true );

And I'm tring to get them into the srcset:

$img_srcset = wp_get_attachment_image_srcset( $img_id, array( 'c200x200', 'c400x400', 'img-movil' ) );
srcset="<?php echo esc_attr( $img_srcset ); ?>

But I get this into the srcset:

    //localhost:3000/app/uploads/2016/12/6e55a1e9-4076-3649-9ebd-b5337b21120b-150x150.jpg 150w, 
    //localhost:3000/app/uploads/2016/12/6e55a1e9-4076-3649-9ebd-b5337b21120b-200x200.jpg 200w, 
    //localhost:3000/app/uploads/2016/12/6e55a1e9-4076-3649-9ebd-b5337b21120b-400x400.jpg 400w"

These are two custom sizes + one default size (150x150). img-movil size is not in the srcset. Why? How can I get the three custom sizes.

If I try to get only img-movil size:

$img_srcset = wp_get_attachment_image_srcset( $img_id, 'img-movil' );

I get the default srceset (there are no custom sizes in srcset):

    "//localhost:3000/app/uploads/2016/12/6e55a1e9-4076-3649-9ebd-b5337b21120b.jpg 631w, 
    //localhost:3000/app/uploads/2016/12/6e55a1e9-4076-3649-9ebd-b5337b21120b-300x240.jpg 300w"

So, It seems there is one image size that doesn't work at all (img-movil).

I tried to regenerate thumbnails, but this behavior persist. Thank you in advance.

1 Answer 1


Pfff... I was four hours around this question and.. I got it. Is a very simple issue: original images are smaller than the custom size. So, custom sizes bigger than original images was not created for this images.

  • I've made that mistake, too! Glad you realized it :)
    – Emil
    Dec 6, 2016 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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