Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<img> attributes are being transfered to the <source> tag, rendering invalid HTML #78

Open
hd-jeroen opened this issue Aug 5, 2024 · 1 comment

Comments

@hd-jeroen
Copy link

hd-jeroen commented Aug 5, 2024

I have created an <img> tag with the attributes alt, decoding, fetchpriority and loading. When NextGenImages converts the image to the WebP all of these attributes are being transfered over to the <source> element which holds the WebP image:

<picture>
    <source type="image/webp" srcset="https://www.ecobouwbescherming.nl/media/wysiwyg/categories/meubellakken.webp" alt="Meubellakken" decoding="async" fetchpriority="high" loading="eager">
    <img src="https://www.ecobouwbescherming.nl/media/wysiwyg/categories/meubellakken.jpg" alt="Meubellakken" decoding="async" fetchpriority="high" loading="eager">
</picture>

As per the HTML spec, this isn't allowed. The <source> HTML element only allows the media, sizes, src, srcset and type attributes. See below screenshot from the W3 HTML validator.

image

Would it be possible to change the NextGenImages implementation to filter out all invalid HTML attributes, thus making the HTML valid again?

@hd-jeroen hd-jeroen changed the title <img> attributes are being transfered to the <source> tag, which isn't always allowed <img> attributes are being transfered to the <source> tag, rendering invalid HTML Aug 5, 2024
@jissereitsma
Copy link
Contributor

Good point: I think the following fix will repair this: c3ad533 (to be released today)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants