Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use srcset and sizes on img element in picture
Previously, in the case where the image has multiple formats and multiple sizes, elventy-img would generate output somewhat like ``` <picture> <source type="image/webp" srcset="/img/KkPMmHd3hP-200.webp 200w, /img/KkPMmHd3hP-400.webp 400w" sizes="100vw"> <source type="image/jpeg" srcset="/img/KkPMmHd3hP-200.jpeg 200w, /img/KkPMmHd3hP-400.jpeg 400w" sizes="100vw"> <img alt="" src="/img/KkPMmHd3hP-200.jpeg" width="400" height="266"> </picture> ``` This change makes eleventy-img instead produce output like ``` <picture> <source type="image/webp" srcset="/img/KkPMmHd3hP-200.webp 200w, /img/KkPMmHd3hP-400.webp 400w" sizes="100vw"> <img alt="" src="/img/KkPMmHd3hP-200.jpeg" srcset="/img/KkPMmHd3hP-200.jpeg 200w, /img/KkPMmHd3hP-400.jpeg 400w" sizes="100vw" width="400" height="266"> </picture> ``` This adds srcset and sizes to the img tag, and doesn't produce a source tag for the same format provided by the img tag. The initial motivation around this was to get RespImageLint to stop complaining by adding srcset and sizes to the img tag. I'm not an HTML expert, and I'm not sure this change is strictly correct.
- Loading branch information