I am using hard-crop on featured images like this :

add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size ( 635, 200, true );

I have no other plugin installed, not even Jetpack.
No matter how large the image I upload wordpress won’t add srcset for my cropped featured images.

EDIT: The problem seems to be with hard crop feature because the srcset shows correctly on any other image posted in article (from media for example). If I deactivate the hard crop the srcset shows correctly on the thumbnails too.

2 Answers
2

To show a srcset, there must be multiple image sizes of the same aspect ratio. When you set your thumbnail to hard crop without creating any other image sizes you are ensuring that there won’t be a srcset.

You might find my answer here helpful.

Briefly, in your case, adding this line:

add_image_size ( 'double-size', 1270, 400, true );

… will make a srcset with both the cropped sizes when you upload a fresh image larger than 1270×400.

Leave a Reply

Your email address will not be published. Required fields are marked *