Hullo! I’ve been putting off implementing images on my site because I keep getting stuck. I use Eleventy, and I have the image plugin working (albeit with earlier versions, I think, since I haven’t updated to Eleventy 3). Right now I’m working on a shortcode that creates an image with a caption. The plan is for it to be the full width of my <main>
section on my website.
<figure class="captioned-image">
<picture>
<source
type="image/avif"
srcset="x-300.avif 300w, x-600.avif 600w, x-700.avif 700w, x-1400.avif 1400w"
sizes="(min-width: 90rem) 50vw, 100vw">
<source
type="image/webp"
srcset="x-300.webp 300w, x-600.webp 600w, x-700.webp 700w, x-1400.webp 1400w"
sizes="(min-width: 90rem) 50vw, 100vw">
<source
type="image/jpeg"
srcset="x-300.jpeg 300w, x-600.jpeg 600w, x-700.jpeg 700w, x-1400.jpeg 1400w"
sizes="(min-width: 90rem) 50vw, 100vw">
<img
src="x-300.jpeg"
width="1400"
height="933"
alt="[alt text]"
loading="lazy"
decoding="async">
</picture>
<figcaption>
<p>[caption text]</p>
<p><a href="x-1400.jpeg">View full size.</a></p>
</figcaption>
</figure>
This is what I have so far. But I get confused when choosing image widths and sizes attributes; I don’t really know what makes sense for my site. This responsive image linter suggested: sizes="(min-width: 800px) 620px, calc(94.58vw - 118px)"
, but I’m not sure what image widths would go with that.
How do other folks pick sizes when doing responsive images?