For some reason Wordpress isn't loading the right image from the server and instead is always taking the one with 960px width, no matter if I open the page with a smartphone or the browser.

This is my image elemnt:

<img class="header-img responsive-img" 
srcset="DSC01834-e1487244486122-350x58.jpg 350w, 
        DSC01834-e1487244486122-768x128.jpg 768w, 
        DSC01834-e1487244486122-960x160.jpg 960w, 
        DSC01834-e1487244486122-560x93.jpg 560w" 
sizes="(min-width: 48em) 960px, 
       (min-width: 35em) 768px, 
       (min-width: 25em) 560px, 
alt="SONY DSC">

Is something wrong with the sizes I specified? Or is the problem somewhere else?

  • What do you mean WordPress not choosing the right image? This happens in the client (your browser) - how are you sure that srcset is being ignored? Which clients have you tested in? – TheDeadMedic Feb 16 '17 at 11:55
  • I've tested in Chrome by looking up the currentSrc in the Inspector under the Properties tab. Since it didn't work there and it always took the 960px image I have not tested in other browsers yet – Smadback Feb 16 '17 at 12:01

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.