
28 November 2026 · 5 min
Serve responsive product images with Cloudflare Workers
One product photo, three jobs. Use srcset and Cloudflare Images to deliver the right file for a catalogue card, a product page and a closer look.




On a product page, shoppers should be able to see the seams on a raincoat. In the catalogue grid, they need to recognise its shape. Sending the same large photo to both views makes a phone download detail it might never display. We start with the space the photo takes up in the layout, then give the browser a few file sizes to choose from.
On November 25, 2026, Cloudflare announced image transformation URLs that work directly on Workers. The interface runs on workers.dev and in local development. You can build a catalogue on a test address using the same transformation paths you plan to use in the store. Cloudflare changelog
Work from the width of the card
Say your phone layout has two cards per row and your desktop cards are 320 CSS pixels wide. In the example below, a 360 pixel viewport gives each image 156 CSS pixels. A screen with a pixel density of three needs about 468 image pixels, so a 480 pixel variant is a reasonable fit. On a desktop display with twice the pixel density, that 320 pixel card has a target of around 640 image pixels.
The srcset attribute tells the browser which widths are available. The sizes attribute describes how wide the image will be in the layout. If the browser works from 100vw when the card only takes half the screen, it can pick a larger file than the layout warrants. Keep sizes with the card component and review it when the grid changes. The browser makes the final choice. HTML Standard on responsive images
<img
src="/cdn-cgi/image/width=480,format=auto/catalog/raincoat-v2.jpg"
srcset="/cdn-cgi/image/width=480,format=auto/catalog/raincoat-v2.jpg 480w,
/cdn-cgi/image/width=800,format=auto/catalog/raincoat-v2.jpg 800w"
sizes="(max-width: 720px) calc(50vw - 24px), 320px"
width="800" height="1000"
alt="Yellow hooded raincoat">
This example assumes the Worker serves an original at /catalog/raincoat-v2.jpg that is at least 800 pixels wide. The HTML width and height establish the aspect ratio. For the product page, we would offer a separate set of candidates. The store can then fetch the full zoom image when a shopper actually opens it. Cloudflare Images URL transformations
Decide how many variants the catalogue needs
Two widths for cards and one larger width for detail views are a reasonable starting point. Set them in the image component so that three parts of the site do not request three slightly different versions for the same card. Give each revision of a product photo a stable URL so you can replace it deliberately.
If the originals come from a separate CMS, configure the source hosts the Worker should accept. Worker settings also apply on connected domains and take precedence over the zone configuration. Local transformations support a subset of the live features, so check the behaviour on a deployed Worker before release. For images stored outside Cloudflare Images, watch how many distinct variants people actually request. Cloudflare meters that usage by unique transformations requested during the calendar month. Worker configuration · Cloudflare Images pricing
Check the download and the first view
Open the catalogue with a cold browser cache at a narrow and a wide viewport. The Network panel shows which candidate was fetched and how many bytes it transferred. For the product page, also check Largest Contentful Paint. If the product photo is the largest visible element on arrival, make its URL discoverable early in the HTML and let the browser load it immediately. Images further down the page can use lazy loading. web.dev on optimising LCP
Start with one category and one product page. Compare image bytes and load times on a phone, then check that buyers can still see the details they need to make a decision. Once both checks pass, reuse the same image component across the catalogue.



