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.

  • from where do you call this. From functions.php? have you attached that sequence to a hook or no?
    – prosti
    Oct 19, 2016 at 0:15
  • do you have other WordPress websites working on that web server?
    – prosti
    Oct 19, 2016 at 0:17
  • interesting problem btw. i never had that problem
    – prosti
    Oct 19, 2016 at 0:19
  • Yes, I call it from functions.php with function srcset_test() { add_theme_support( 'post-thumbnails' ); add_image_size( 'custom-thumbnail', 635, 230, true ); } add_action( 'after_setup_theme', 'srcset_test' ); I have no other site on this server but I forgot to mention that the srcset works for images posted in articles from gallery or media.
    – Grim
    Oct 19, 2016 at 7:07

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 1270x400.

  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Howdy_McGee
    Oct 19, 2016 at 20:03

You can create a css class and use this with any height or weight

    <div class="pbheader" style="background-image:url('<?=get_post_image_url(); ?>')"></div>

.pbheader {
    position: relative;
    background-size: 100%;
    height: 260px;
    background-position: left;
    background-repeat: no-repeat;

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.