srcset attribute is output in the rendered DOM but not in the page source
-
Hi Florian,
Thanks for such a great plugin.
After the DOM is rendered everything is OK but the issue is in the source code of the page –which should be valid HTML code–. If we take a look at the source code of the page without the plugin active, images are output correctly, with the srcset attribute, e.g. something like:
<img itemprop="contentURL" src="https://mysite.com/wp-content/uploads/image.jpg" alt="Alttext" width="940" height="576" class="size-full wp-image-17304" srcset="https://mysite.com/wp-content/uploads/image.jpg 940w, https://mysite.com/wp-content/uploads/image-640x392.jpg 640w, https://mysite.com/wp-content/uploads/image-460x282.jpg 460w, https://mysite.com/wp-content/uploads/image-200x123.jpg 200w, https://mysite.com/wp-content/uploads/image-400x245.jpg 400w, https://mysite.com/wp-content/uploads/image-259x159.jpg 259w" sizes="(max-width: 940px) 100vw, 940px" />
But when the plugin is active, the source code of the page becomes:
<img itemprop="contentURL" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" alt="Alttext" width="940" height="576" class="size-full wp-image-17304 lazyload" sizes="(max-width: 940px) 100vw, 940px" data-srcset="https://mysite.com/wp-content/uploads/image.jpg 940w, https://mysite.com/wp-content/uploads/image-640x392.jpg 640w, https://mysite.com/wp-content/uploads/image-460x282.jpg 460w, https://mysite.com/wp-content/uploads/image-200x123.jpg 200w, https://mysite.com/wp-content/uploads/image-400x245.jpg 400w, https://mysite.com/wp-content/uploads/image-259x159.jpg 259w" data-src="https://mysite.com/wp-content/uploads/image.jpg" data-aspectratio="940/576">
As you can see, the sizes attribute is present but the srcset attribute is missing. By the HTML spec, “The sizes attribute may be specified only if the srcset attribute is also present”.
- The topic ‘srcset attribute is output in the rendered DOM but not in the page source’ is closed to new replies.