Captain_Planet
Captain_Planet

Reputation: 1338

WordPress and the srcset image attribute

I'm using WordPress 4.9.4. Ive noticed that when viewing my blogs on a mobile, the images are far too wide. I'm sure this never used to happen, but don't quote me on this.

Anyway, as part of debugging I noticed the srcset attribute on all my images. And I understand what this functionality is providing by reading this post.

However, my images are not getting resized accordingly - they are staying at full size (I've tried in different browsers, clearing caches and chrome ingognito mode). And I have a feeling it's because when they have been inserted into each post, they have 'height' and 'width' attributes on every image tag.

Moving forwards i can probably use this method. But what do I do with all my historic posts? Is including the height and width attributes good or bad practise in relation to srcset?

Thanks.

Upvotes: 1

Views: 263

Answers (1)

Kuba Niewiarowski
Kuba Niewiarowski

Reputation: 38

.your-post img {
    max-width: 100%;
    height: auto;
}

if I understood you correctly.

Upvotes: 0

Related Questions