# Use srcset and sizes

- Check 16.06 · Images and multimodal search · Important
- Source: https://checklist-seo-geo.com/en/images-multimodal-search/use-srcset-sizes
- Offer several image sizes with srcset, describe the displayed width with sizes, and apply it in WordPress, Shopify, Drupal or Next.js.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/images-multimodal-search/use-srcset-sizes.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

The `srcset` attribute lists several versions of the same image (400, 800, 1,600 pixels wide); the `sizes` attribute tells the browser what width the image will take up on screen. With these two pieces of information, the browser downloads the smallest version that is sufficient for the visitor's screen: a phone no longer receives the image intended for a desktop screen. Once the task is done, every content image has variants, a `sizes` value that matches the layout, and a valid fallback `src`.

## Why it matters

The browser chooses the image before it has computed the layout: it does not yet know how wide the element will be. Without `sizes`, it assumes the image spans the full width of the viewport (`100vw`) and picks a variant far too large for a grid thumbnail. With an accurate `sizes`, it multiplies the announced width by the screen density and chooses the nearest variant that is at least that large.

Example: an image displayed at 384 pixels on a phone with a density of 3 needs a variant of about 1,150 pixels; on a computer with a density of 1, a 400-pixel variant is enough.

On the search engine side, Google supports `srcset` and `<picture>`, but points out that some crawlers do not understand them: the `src` attribute must always contain a valid image URL. This `src` is also what many tools that do not emulate a full browser read.

## What it improves

- **Page weight on mobile**: the most direct effect, often several hundred kilobytes per image-heavy page.
- **LCP** (Largest Contentful Paint): the main image arrives faster. See [target LCP ≤ 2.5 s at the 75th percentile](https://checklist-seo-geo.com/en/performance-core-web-vitals/target-lcp-25-s-at-75th-percentile).
- **Sharpness**: high-density screens receive a large enough variant.
- **Lighthouse audit**: fewer images flagged as oversized in the “Improve image delivery” insight.
- **Rankings and Google Images**: no direct effect; what matters is keeping a crawlable fallback `src`.

## How to check

In the browser console, for each image that has a `srcset`:

```js
console.table([...document.querySelectorAll('img[srcset], picture img')].map((img) => ({
  file: (img.currentSrc || '').split('/').pop().split('?')[0].slice(0, 40),
  sizes: img.getAttribute('sizes') || '(MISSING)',
  displayed: Math.round(img.getBoundingClientRect().width),
  density: devicePixelRatio,
  src: img.getAttribute('src') ? 'yes' : '(MISSING)',
})));
```

What to check:

- **`sizes` missing** while the `srcset` uses `w` descriptors: the browser assumes `100vw`.
- **`currentSrc`**: the chosen variant should have a width close to `displayed × density`. Reload in the developer tools' responsive mode, at mobile width then desktop width: the chosen file should change.
- **`src` missing**: no fallback for crawlers and tools that ignore `srcset`.

To check a `sizes` value, compare the announced width with the image's actual width at several viewport widths. A gap of a few pixels has no effect; a `sizes` that announces `100vw` for a 300-pixel thumbnail needs fixing.

PageSpeed Insights flags images larger than their display size, with the possible savings.

## How to implement

### Before you start

Target markup for a fluid image:

```html
<img src="/images/atelier-800.jpg"
     srcset="/images/atelier-400.jpg 400w,
             /images/atelier-800.jpg 800w,
             /images/atelier-1200.jpg 1200w,
             /images/atelier-1600.jpg 1600w"
     sizes="(min-width: 1200px) 760px, (min-width: 768px) 66vw, calc(100vw - 32px)"
     width="1600" height="1067"
     alt="TIG welding station in the workshop" loading="lazy" decoding="async">
```

Syntax rules:

- **`w` descriptor**: the actual width of the file, in pixels. This is the general case.
- **`x` descriptor**: for a fixed-size image (logo, avatar), `srcset="/logo-160.png 1x, /logo-320.png 2x"`, without `sizes`.
- **`sizes`**: a list of media conditions each followed by a width, then a default width with no condition. The browser takes the first true condition: put the largest screen widths first. Accepted units: `px`, `vw`, `em`, and `calc()`, never percentages.
- **`src`**: a medium variant, for browsers and crawlers that ignore `srcset`.

Write `sizes` from the layout. Example of a card grid: one column on mobile with a 16-pixel margin on each side, two columns on tablet, three columns in a 1,200-pixel container on desktop, 24 pixels of gap between columns:

| Screen width | Image width | Value for `sizes` |
| --- | --- | --- |
| 1,200 px and up | (1,200 − 2 × 24) ÷ 3 = 384 px | `(min-width: 1200px) 384px` |
| 768 to 1,199 px | half the screen minus the margins | `(min-width: 768px) calc(50vw - 28px)` |
| under 768 px | the full screen minus 32 px | `calc(100vw - 32px)` |

Result: `sizes="(min-width: 1200px) 384px, (min-width: 768px) calc(50vw - 28px), calc(100vw - 32px)"`.

Variants to generate: from the smallest displayed width to the largest displayed width multiplied by two, with steps of 30 to 50%. Four to six variants are enough in most cases. See [size images appropriately](https://checklist-seo-geo.com/en/images-multimodal-search/size-images-appropriately).

**Deferred images**: for an image with `loading="lazy"`, the browser knows the layout by the time it downloads it. The `sizes="auto"` value lets it use the actual width. It is only valid with `loading="lazy"` and is not recognized everywhere: add a fallback list.

```html
<img src="/images/atelier-800.jpg" srcset="…" sizes="auto, (min-width: 1200px) 760px, 100vw" loading="lazy" …>
```

**Art direction**: for a different crop depending on the screen (a panoramic visual on desktop, cropped square on mobile), use `<picture>` with the `media` attribute:

```html
<picture>
  <source media="(max-width: 767px)" srcset="/images/hero-carre-600.jpg 600w, /images/hero-carre-1200.jpg 1200w" sizes="100vw" width="1200" height="1200">
  <img src="/images/hero-1600.jpg" srcset="/images/hero-1200.jpg 1200w, /images/hero-1600.jpg 1600w, /images/hero-2400.jpg 2400w"
       sizes="100vw" width="2400" height="1000" alt="Manufacturing workshop seen from the entrance" fetchpriority="high">
</picture>
```

### Cloudflare

Versions: Cloudflare Images (image transformations), all plans, November 2026.

With image transformations, a single original is enough: each `srcset` entry requests a different width.

```html
<img src="/cdn-cgi/image/width=800,format=auto/images/atelier.jpg"
     srcset="/cdn-cgi/image/width=400,format=auto/images/atelier.jpg 400w,
             /cdn-cgi/image/width=800,format=auto/images/atelier.jpg 800w,
             /cdn-cgi/image/width=1600,format=auto/images/atelier.jpg 1600w"
     sizes="(min-width: 1200px) 760px, 100vw" width="1600" height="1067" alt="TIG welding station in the workshop">
```

Keep a short, fixed list of widths: each distinct width is a transformation, billed beyond the free volume.

### WordPress

Versions: WordPress 6.4 and later (`sizes="auto"` from 6.7).

WordPress automatically adds `srcset` and `sizes` to images inserted in content and to those produced by `wp_get_attachment_image()` and `the_post_thumbnail()`, based on the sizes generated on upload. The default `sizes` value is `(max-width: {width}px) 100vw, {width}px`: accurate for an image spanning the full column width, too wide for an image in a grid. Correct it according to context:

```php
add_filter('wp_calculate_image_sizes', function (string $sizes, array|string $size): string {
    if (! is_array($size)) {
        return $sizes;
    }

    if (! is_singular('post')) {
        return $sizes;
    }

    if ($size[0] < 760) {
        return $sizes;
    }

    return '(min-width: 1200px) 760px, calc(100vw - 32px)';
}, 10, 2);
```

In a template, pass `sizes` directly:

```php
echo wp_get_attachment_image($attachment_id, 'large', false, [
    'sizes' => '(min-width: 1200px) 384px, (min-width: 768px) calc(50vw - 28px), calc(100vw - 32px)',
]);
```

Since WordPress 6.7, images with `loading="lazy"` also receive `sizes="auto"`. Images hard-coded in the theme (`<img src="…">`) have no `srcset`: go through `wp_get_attachment_image()`. The `max_srcset_image_width` filter (2,048 pixels by default) limits the largest variant offered.

### Shopify

Versions: Online Store 2.0 themes, Liquid, November 2026.

The `image_tag` filter generates a `srcset` with default widths up to the width requested in `image_url`. Specify your widths and your `sizes`:

```liquid
{{ product.featured_image | image_url: width: 1200 | image_tag:
  widths: '300, 450, 600, 900, 1200',
  sizes: '(min-width: 1200px) 384px, (min-width: 768px) calc(50vw - 28px), calc(100vw - 32px)',
  alt: product.featured_image.alt }}
```

Recent themes often compute `sizes` from the number of columns set in the theme editor: if you change the grid, check that `sizes` follows.

### PrestaShop

Versions: PrestaShop 8 and 9, Classic and Hummingbird themes.

The Hummingbird theme already produces `srcset` and `sizes` for product thumbnails: just check that `sizes` matches your grid. The Classic theme, on the other hand, only displays one size. In a Classic child theme, add the `srcset` in `templates/catalog/_partials/miniatures/product.tpl` using the available image types (`product.cover.bySize`), declaring the actual width of each type.

Since PrestaShop 8.1, Classic places the image in a `<picture>` element with AVIF and WebP sources when those formats are generated. The browser then picks a `<source>` and ignores the `srcset` of the `<img>`: put the same list of widths on each source. The conditions below keep the code valid on PrestaShop 8.0 as well, without additional formats:

```html
<picture>
  {if !empty($product.cover.bySize.home_default.sources.avif)}
    <source type="image/avif"
            srcset="{$product.cover.bySize.home_default.sources.avif} {$product.cover.bySize.home_default.width}w,
                    {$product.cover.bySize.medium_default.sources.avif} {$product.cover.bySize.medium_default.width}w,
                    {$product.cover.bySize.large_default.sources.avif} {$product.cover.bySize.large_default.width}w"
            sizes="(min-width: 1200px) 260px, (min-width: 768px) 33vw, 50vw">
  {/if}
  {if !empty($product.cover.bySize.home_default.sources.webp)}
    <source type="image/webp"
            srcset="{$product.cover.bySize.home_default.sources.webp} {$product.cover.bySize.home_default.width}w,
                    {$product.cover.bySize.medium_default.sources.webp} {$product.cover.bySize.medium_default.width}w,
                    {$product.cover.bySize.large_default.sources.webp} {$product.cover.bySize.large_default.width}w"
            sizes="(min-width: 1200px) 260px, (min-width: 768px) 33vw, 50vw">
  {/if}
  <img src="{$product.cover.bySize.home_default.url}"
       srcset="{$product.cover.bySize.home_default.url} {$product.cover.bySize.home_default.width}w,
               {$product.cover.bySize.medium_default.url} {$product.cover.bySize.medium_default.width}w,
               {$product.cover.bySize.large_default.url} {$product.cover.bySize.large_default.width}w"
       sizes="(min-width: 1200px) 260px, (min-width: 768px) 33vw, 50vw"
       width="{$product.cover.bySize.home_default.width}" height="{$product.cover.bySize.home_default.height}"
       alt="{$product.cover.legend}" loading="lazy">
</picture>
```

Adapt the type names to those defined in `Design > Image Settings`, then clear the cache.

### Magento

Versions: Magento Open Source and Adobe Commerce 2.4, Luma theme.

The Luma theme does not produce a `srcset` for catalog thumbnails. Add image types in `etc/view.xml`, then override the thumbnail template (`Magento_Catalog/templates/product/image_with_borders.phtml`) to build the `srcset` from the URLs of these types. The Hyvä theme handles responsive images more directly; refer to its documentation.

### Drupal

Versions: Drupal 10 and 11.

Enable the core Responsive Image module. In `Configuration > Media > Responsive image styles`, create a style, choose the theme's breakpoint group, then, for a fluid image, the “Select multiple image styles and use the sizes attribute” option: check the image styles that will serve as variants and enter the `sizes` value. Assign this style to the image field in `Manage display`.

### Wix

Versions: Wix Editor and Wix Studio, Squarespace 7.1, November 2026.

Automatic: Wix produces the variants and chooses the size according to the screen. So does Squarespace. No setting is exposed.

### Webflow

Versions: Webflow Designer, all plans, November 2026.

Webflow automatically generates variants and a `srcset` for Image elements whose image was uploaded to the assets. Background images and images inserted through custom code do not benefit from this.

### Laravel

Versions: Laravel 11 to 13, spatie/laravel-medialibrary 11.

A Blade component builds the markup from the variants generated on upload. In `resources/views/components/responsive-image.blade.php`:

```html
@props(['name', 'alt', 'widths' => [400, 800, 1200, 1600], 'sizes' => '100vw', 'width', 'height'])

<img src="{{ asset("images/{$name}-800.webp") }}"
     srcset="{{ collect($widths)->map(fn ($w) => asset("images/{$name}-{$w}.webp") . " {$w}w")->implode(', ') }}"
     sizes="{{ $sizes }}" width="{{ $width }}" height="{{ $height }}" alt="{{ $alt }}"
     {{ $attributes->merge(['loading' => 'lazy', 'decoding' => 'async']) }}>
```

Usage:

```html
<x-responsive-image name="atelier" alt="TIG welding station in the workshop" width="1600" height="1067"
                    sizes="(min-width: 1200px) 760px, calc(100vw - 32px)" />
```

With spatie/laravel-medialibrary and `withResponsiveImages()`, a media item's `toHtml()` method directly produces a tag with `srcset`.

### Next.js

Versions: Next.js 15 and 16 (App Router and Pages Router).

With `next/image`, the `sizes` property changes how the `srcset` is generated: without it, a fixed-width image only receives `1x` and `2x` variants; with it, width-based variants drawn from `deviceSizes` and `imageSizes`.

```js
<Image
  src={atelier}
  alt="TIG welding station in the workshop"
  sizes="(min-width: 1200px) 384px, (min-width: 768px) 50vw, 100vw"
  style={{ width: '100%', height: 'auto' }}
/>
```

With `fill`, `sizes` is essential: without it, Next.js assumes the image spans the full width of the viewport.

### Nuxt

Versions: Nuxt 3 and 4, @nuxt/image module 1 and 2.

`NuxtImg` generates the `srcset` from `sizes`, expressed per `image.screens` breakpoint:

```html
<NuxtImg src="/images/atelier.jpg" sizes="100vw sm:50vw lg:384px" width="1600" height="1067"
         alt="TIG welding station in the workshop" loading="lazy" />
```

For a fixed-size image, `densities="x1 x2"` produces `x` descriptors.

### Astro

Versions: Astro 5 to 7 (`layout` property from Astro 5.10).

With `layout="constrained"` or `layout="full-width"` (Astro 5.10 and later), `srcset` and `sizes` are generated automatically. Otherwise, declare them yourself; `sizes` is required with `widths`:

```html
<Image src={atelier} alt="TIG welding station in the workshop"
       widths={[400, 800, 1200, 1600]} sizes="(min-width: 1200px) 760px, 100vw" />
```

Widths larger than the original are ignored.

## Common mistakes

- **Forgetting `sizes`** with `w` descriptors: the browser assumes `100vw` and downloads a variant too large for thumbnails.
- **Putting `sizes="100vw"` everywhere** by copy-pasting, including in a three-column grid.
- **Declaring a wrong width in `srcset`** (`800w` on a 1,600-pixel file): the browser makes the wrong choice.
- **Ordering `sizes` conditions from the smallest to the largest screen**: the first true condition wins, the following ones are never used.
- **Removing the `src`**: no more fallback for crawlers that ignore `srcset`.
- **Putting `alt`, `loading` or `fetchpriority` on the `<source>` elements**: these attributes only apply to the `<img>`.
- **Using `sizes="auto"` without `loading="lazy"`**: the value is invalid and the browser falls back to `100vw`.
- **Offering dozens of variants**: less efficient caching and wasted storage, with no measurable gain.

## Frequently asked questions

### What is the difference between srcset and sizes?

The srcset attribute lists the available files and their actual width, for example 400w, 800w and 1600w. The sizes attribute states the width the image will take up in the page depending on the screen size. The browser combines both with the screen density to download the smallest sufficient variant. Without sizes, it assumes the image spans the full width of the viewport.

### Should I use picture or srcset?

Use srcset on the img element when only the size changes, which covers most images. Keep picture for two cases: offering several formats, such as AVIF and WebP with a JPEG fallback, or changing the crop depending on the screen with the media attribute. In every case, keep an img with a valid src, which Google recommends for crawlers that ignore these attributes.

### Does Google index images declared in srcset?

Google supports srcset and picture for responsive images, but points out that some browsers and crawlers do not understand them. It therefore asks you to always provide a fallback URL in the src attribute of the img element. Point that src to a variant of a good size, large enough for a sharp result thumbnail, rather than to the smallest one.

### Does WordPress handle srcset and sizes automatically?

Yes for images inserted in content and those produced by wp_get_attachment_image or the_post_thumbnail: WordPress adds srcset and sizes based on the sizes generated on upload. The default sizes value assumes an image spanning the full column width; correct it with the wp_calculate_image_sizes filter for grids. Images hard-coded in the theme do not benefit from this.

## Resources

- [MDN: responsive images](https://developer.mozilla.org/en-US/docs/Web/HTML/Guides/Responsive_images)
- [MDN: srcset property](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/srcset) and [sizes](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/sizes)
- [web.dev: responsive images](https://web.dev/learn/design/responsive-images)
- [WHATWG: images specification](https://html.spec.whatwg.org/multipage/images.html)
- [Google Search Central: responsive images](https://developers.google.com/search/docs/appearance/google-images)
- [WordPress: wp_calculate_image_sizes filter](https://developer.wordpress.org/reference/hooks/wp_calculate_image_sizes/) and [auto sizes in 6.7](https://make.wordpress.org/core/2024/10/18/auto-sizes-for-lazy-loaded-images-in-wordpress-6-7/)
- [Shopify: image_tag filter](https://shopify.dev/docs/api/liquid/filters/image_tag)
- [Next.js: sizes property](https://nextjs.org/docs/app/api-reference/components/image)
- [Astro: image reference](https://docs.astro.build/en/reference/modules/astro-assets/)

Next steps: [set width/height](https://checklist-seo-geo.com/en/images-multimodal-search/set-width-height) and [use WebP/AVIF if appropriate](https://checklist-seo-geo.com/en/images-multimodal-search/use-webp-avif-if-appropriate).
