eleventy-img icon indicating copy to clipboard operation
eleventy-img copied to clipboard

Inconsistent output across raster and vector images (`format`, `svgShortCircuit`, `<picture>`)

Open patrulea opened this issue 6 months ago • 0 comments

I’m doing everything I can to avoid <picture> tags around my images. So, I only have one format output for vectors (SVG, svgShortCircuit: true) and one for rasters (AVIF).

Vectors (SVG) render as expected, as they’re not being processed by the plugin:

<img loading="lazy" decoding="async" src="/assets/se9zzRa3OT-176.svg" width="176" height="28">

Rasters (AVIF) do come wrapped within an annoying and redundant <picture> element.

<picture>
  <img draggable="false" loading="lazy" decoding="async" src="/assets/WCcmWdt85q-240.avif" width="1920" height="1536" srcset="/assets/WCcmWdt85q-240.avif 240w, /assets/WCcmWdt85q-480.avif 480w, /assets/WCcmWdt85q-960.avif 960w, /assets/WCcmWdt85q-1920.avif 1920w" sizes="100vw">
</picture>

This happens because my formats array contains more than one element (["svg", "avif"]) but, in practice, the output is always a single format. For this combination of settings, the plugin should make an exception and output consistent markup, preferably one without the <picture> wrapper.

Related: #62

patrulea avatar Aug 23 '24 22:08 patrulea