I am modifying a theme, using a child theme, and in a template file (single.php) I need to display a large post thumbnail, so I have this code:
In Settings > Media, the large size is set to max width = 1024px and max height = 1024px (I suppose these are the default settings in WordPress). Now, the problem is that in the post page I get this html code:
class=”attachment-large size-large wp-post-image” alt=””
sizes=”(max-width: 800px) 100vw, 800px” width=”800″ height=”533″>
The result is that I get a 800px-wide picture, instead of a true “large” image that should be 1024px-wide. The problem seems to be in the “sizes” attribute that sets the max width to 800px, and the “width” attribute that sets the image to 800px. Those seem wrong to me. So what is happening exactly? If it’s caused by something in the theme, how do I find out where it is so that I can change it?
Looking at the documentation related to the_post_thumbnail(), I saw these filters:
So I tried looking for the string “post_thumbnail” and “attachment_image” in the theme, but that didn’t bring up anything useful. So what else do I look for? Note that I have some plugins installed (like Advanced Custom Fileds, etc.) but I tried deactivating them and the problem was still there, so I believe the source of the problem must be the theme, or something I don’t understand about WordPress.
Read more here:: Unexpected width and srcset attributes for the_post_thumbnail();