Framework · Imagery · 3 min read
Responsive image checklist
Six things every product image needs before it ships (widths, sizes, crops, dimensions, loading priority and alt text), so each screen gets a sharp file that is no bigger than it needs and the page doesn't jump.
A few standard file widths, made from one master.
srcset: 480, 960, 1600How wide the image is on screen at each breakpoint.
100vw on phones, 40remA new crop only where the subject would be lost.
picture, or a focal pointWidth and height on every image, so nothing jumps.
width="1600" height="900"The first screen loads first; the rest waits.
fetchpriority, loading="lazy"Written by someone who knows why the image is there.
On theimg, not the sourceUse it when
- You hand off a new page or component with photos, and developers ask "which sizes?"
- A page feels slow on phones, or jumps while it loads.
- A hero crop that works on desktop loses its subject on a phone.
How to use it
- Agree the standard widths. Pick a small set of file widths the team generates for every photo, for example 480, 960 and 1600, and make them automatically from one master. Output: the
srcsetlist for every image. - Write the width on screen per breakpoint. For each image, say how wide it is at each breakpoint: full width on phones, 40rem on desktop, and so on. That becomes
sizes. Output: asizesvalue that matches the layout. - Decide crop or focal point. If the subject would be lost or cut on a phone, give the phone its own crop with
<picture>. Otherwise keep one crop and mark the focal point. Output: crops and their breakpoint, or one focal point. - Give every image its shape. Every
imggetswidthandheight(or a CSSaspect-ratio), so the browser keeps the space before the file arrives. Output: no layout shift from images. - Set the loading priority. The image in the first screen loads first, never lazy, and gets
fetchpriority="high"if it's the largest element. Everything further down getsloading="lazy". Output: one priority line per image. - Write the alt text. Someone who knows why the image is there writes it. Inside
<picture>, it goes on theimg. Output: alt text, oralt=""for a decorative image.
Worked example
The bakery ordering app adds a seasonal hero and a grid of product cards. The handoff for the hero: widths 480, 960, 1600; sizes="(max-width: 560px) 100vw, 40rem"; a tall phone crop below 560px because the wide shot turns the loaf into a crumb; width="1600" height="900"; loads first with fetchpriority="high"; alt "A round seeded sourdough loaf on a wooden board." The product cards: the same widths, sizes="(max-width: 560px) 50vw, 15rem", one crop with the focal point on the bread, width="480" height="320", loading="lazy", alt text per product. The developer didn't have to guess anything.
Watch out for
- One huge file for every screen. It looks fine on your monitor and costs every phone user several times what it should.
- A
sizesthat doesn't match the layout. The browser trusts it and downloads the wrong file. Update it when the layout changes. - Lazy-loading the hero. It always delays the largest thing on screen. Lazy loading is for images below the first screen.
- Art direction everywhere. A separate crop for every image is work nobody needs. Use it only where the subject would be lost.
Template
Copy one block per image into the handoff.
Image: ...
Widths (srcset): 480, 960, 1600 (team standard)
Width on screen (sizes): phone ... / tablet ... / desktop ...
Crop: one crop, focal point at ... OR phone crop below ...px: ...
Dimensions: width ... height ... (or aspect-ratio ...)
Priority: first screen, fetchpriority="high" OR loading="lazy"
Format and quality: ...
Alt text: "..." (or alt="" if decorative)
- High Performance ImagesColin Bendell, Tim Kadlec, Yoav Weiss, Guy Podjarny, Nick Doyle and Mike McCallBook · 2016 (Amazon)
- Using responsive images in HTMLMDN (external site)
- pictureMDN (external site)
- Learn Imagesweb.dev (external site)
- Optimize CLSweb.dev (external site)
- Optimize LCPweb.dev (external site)
"See on Amazon" links are affiliate links. As an Amazon Associate I earn from qualifying purchases, at no extra cost to you.