Check 16.03 · Images and multimodal search

Use WebP/AVIF if appropriate

Serve your images as WebP or AVIF with a JPEG fallback via picture, Apache, Nginx, Cloudflare, WordPress, Shopify or Next.js, and know when to keep JPEG.

Priority
Important
Difficulty
Intermediate
Estimated time
1 h to 1 day
Free, no account: your progress is saved in this browser.

Ask an AI to check this point on your site

Opens the assistant with a ready-made question: this check, its goal and your site URL.

For Gemini, Copilot or another assistant, copy the question. The link opens the chosen service directly: nothing goes through this site.

In short

WebP and AVIF are image formats more recent than JPEG and PNG: at comparable visual quality, they produce much lighter files. All current browsers read them and Google Search indexes them. The task is to serve them to browsers that accept them, with a JPEG or PNG fallback for the others, and to keep the classic formats where they are still needed (social sharing image, Merchant Center feeds, emails). Expected result: the site's photos and illustrations go out as AVIF or WebP, with no broken image anywhere.

Why it matters

Google states that its lossy WebP files are 25 to 34% smaller than comparable JPEGs, and that lossless WebP is 26% smaller than PNG. The Next.js documentation sums up the following gap: AVIF compresses about 20% better than WebP, but takes about 50% longer to encode. These figures vary widely from one image to another; measure on your own.

On the search engine side, Google Search indexes BMP, GIF, JPEG, PNG, WebP, SVG and AVIF images referenced in the src attribute of an <img>, and asks that the extension match the real format. It also points out that some crawlers do not understand <picture> or srcset: the src attribute of the <img> must always point to a valid image.

“If appropriate” is not a stylistic precaution. Some uses do not tolerate these formats:

Use Recommended format Reason
Photos and content visuals AVIF or WebP, JPEG fallback Maximum weight savings
Screenshots, flat-color illustrations Lossless WebP or optimized PNG Sharp text and edges
Logos, icons, simple diagrams SVG Vector, light, sharp at any size
Animations MP4 or WebM video, otherwise animated WebP An animated GIF often weighs several megabytes
Sharing image (og:image) JPEG or PNG Uneven support for recent formats across sharing platforms
Google Merchant Center feeds JPEG, WebP or PNG AVIF is not in the list of accepted formats
Emails JPEG, PNG or GIF Support for recent formats varies widely across email clients

What it improves

  • Page weight Often the biggest gain in a performance audit.
  • LCP (Largest Contentful Paint, display of the largest visible element): the main image downloads faster. See optimize the LCP image without lazy loading (opens in a new tab).
  • Lighthouse audit The “Improve image delivery” insight lists fewer files.
  • Costs Fewer bytes served by the host and the CDN (Content Delivery Network).
  • Google Images No direct effect on rankings; recent formats are simply indexed just like JPEG.

How to check

Request an image while announcing AVIF and WebP support, as a browser does, then read the type returned:

curl -s -o /dev/null -D - -H "Accept: image/avif,image/webp,*/*" https://example.com/images/atelier.jpg | grep -i -E "^(content-type|vary|cf-polished|content-length):"

Compliant result with negotiation by the server or the CDN: content-type: image/avif or image/webp, with vary: Accept. With the <picture> element, the .jpg URL stays JPEG: this is normal, check the markup instead.

In the browser, Network tab, “Img” filter, “Type” column: photos should appear as avif or webp. The console lists images still served as JPEG or PNG:

performance.getEntriesByType('resource')
  .filter((entry) => entry.initiatorType === 'img' && /\.(jpe?g|png)(\?|$)/i.test(entry.name))
  .map((entry) => `${Math.round(entry.encodedBodySize / 1024)} KB ${entry.name}`);

PageSpeed Insights, “Improve image delivery” insight, estimates the possible savings file by file. See analyze PageSpeed Insights and Lighthouse (opens in a new tab).

How to implement

Before you start

Three methods, to choose according to your environment:

Method Principle When to choose it
<picture> element The HTML offers AVIF, WebP and JPEG; the browser chooses Code under your control, no transforming CDN; the safest
Conversion by the CDN or platform Same URL, format chosen from the Accept header Cloudflare, CloudFront, Shopify, Next.js: the simplest
Negotiation by the web server The server serves photo.jpg.webp instead of photo.jpg Existing site with templates that are hard to change

Target markup with <picture>:

<picture>
  <source type="image/avif" srcset="/images/atelier-800.avif 800w, /images/atelier-1600.avif 1600w" sizes="(max-width: 800px) 100vw, 800px">
  <source type="image/webp" srcset="/images/atelier-800.webp 800w, /images/atelier-1600.webp 1600w" sizes="(max-width: 800px) 100vw, 800px">
  <img src="/images/atelier-800.jpg" srcset="/images/atelier-800.jpg 800w, /images/atelier-1600.jpg 1600w" sizes="(max-width: 800px) 100vw, 800px"
       width="800" height="533" alt="TIG welding station in the workshop" loading="lazy" decoding="async">
</picture>

The alt, width, height, loading and fetchpriority attributes go on the <img>. A <source> element only accepts width and height for a crop that differs from the <img>. See use srcset and sizes (opens in a new tab).

Command-line conversion, with the official libwebp (cwebp) and libavif (avifenc) tools or ImageMagick:

cwebp -q 80 atelier.jpg -o atelier.webp
avifenc -q 60 atelier.jpg atelier.avif
magick atelier.jpg -quality 80 atelier.webp

Quality scales differ from one encoder to another: compare visually, for example in Squoosh, before rolling out a setting. See compress images (opens in a new tab).

Warning: behind a CDN, negotiation by the origin server is risky. If the CDN ignores the Vary: Accept header, it may cache the AVIF version and serve it to a browser that cannot read it. In that case, use <picture> or the CDN's conversion.

Apache

Versions Apache 2.4.

Negotiation method: generate atelier.jpg.avif and atelier.jpg.webp next to each atelier.jpg, then add to the .htaccess at the site root:

<IfModule mod_mime.c>
    AddType image/avif .avif
    AddType image/webp .webp
</IfModule>

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{HTTP_ACCEPT} image/avif
    RewriteCond %{REQUEST_FILENAME} \.(jpe?g|png)$
    RewriteCond %{REQUEST_FILENAME}.avif -f
    RewriteRule \.(jpe?g|png)$ %{REQUEST_URI}.avif [T=image/avif,L]

    RewriteCond %{HTTP_ACCEPT} image/webp
    RewriteCond %{REQUEST_FILENAME} \.(jpe?g|png)$
    RewriteCond %{REQUEST_FILENAME}.webp -f
    RewriteRule \.(jpe?g|png)$ %{REQUEST_URI}.webp [T=image/webp,L]
</IfModule>

<IfModule mod_headers.c>
    <FilesMatch "\.(jpe?g|png|avif|webp)$">
        Header merge Vary Accept
    </FilesMatch>
</IfModule>

In a <VirtualHost> block rather than an .htaccess, replace %{REQUEST_FILENAME} with %{DOCUMENT_ROOT}%{REQUEST_URI}, then run sudo apachectl configtest && sudo systemctl reload apache2. An image without a converted version keeps being served as JPEG or PNG.

Nginx

Versions Nginx 1.18 and later.

In the http context (for example /etc/nginx/conf.d/images.conf), choose the suffix according to the Accept header:

map $http_accept $img_suffix {
    default        "";
    "~*image/avif" ".avif";
    "~*image/webp" ".webp";
}

Then in the site's server block:

location ~* \.(?:jpe?g|png)$ {
    add_header Vary Accept;
    try_files $uri$img_suffix $uri =404;
}

The map expressions are tested in order: a browser that accepts AVIF receives atelier.jpg.avif. If that file is missing, Nginx serves the original, not the WebP version: generate both formats. The mime.types file shipped with Nginx contains the line image/avif avif; since version 1.21.4; on an older version or a file replaced by the distribution, check /etc/nginx/mime.types and add it if it is missing, then run sudo nginx -t && sudo systemctl reload nginx.

Cloudflare

Versions Cloudflare dashboard, Polish on Pro, Business and Enterprise plans, image transformations on all plans, November 2026.

Two features, without touching the templates:

  • Polish (Pro, Business and Enterprise plans): in the domain, Speed > Settings > Image Optimization (optimization), choose Lossless or Lossy, then enable WebP and AVIF. Polish keeps the same URLs and only serves these formats to browsers that announce them; it converts JPEGs to WebP only in Lossy mode. It skips images whose origin returns a Vary header other than Vary: Accept-Encoding: do not enable the Apache or Nginx negotiation described above at the same time.
  • Image transformations: enable them for the zone in the account dashboard (Images > Transformations), then request images through a URL of the form /cdn-cgi/image/width=800,format=auto/images/atelier.jpg. format=auto serves the most efficient format accepted by the browser. Usage-based billing beyond a free volume: check the pricing.

Purge the cache after enabling them (Caching > Configuration, “Purge Everything”).

AWS

Versions AWS console (CloudFront, S3), Dynamic Image Transformation for Amazon CloudFront solution, November 2026.

CloudFront does not convert images on its own. Two options:

  • Deploy the AWS “Dynamic Image Transformation for Amazon CloudFront” solution (formerly Serverless Image Handler), which resizes images and serves the format best suited to the browser from originals stored in S3.
  • Generate the AVIF and WebP versions at build or upload time, and use <picture>.

S3 serves the content type recorded at upload: specify it for recent formats.

aws s3 cp ./images/ s3://mon-bucket/images/ --recursive --exclude "*" --include "*.avif" --content-type image/avif
aws s3 cp ./images/ s3://mon-bucket/images/ --recursive --exclude "*" --include "*.webp" --content-type image/webp

If you negotiate the format at the origin, add the Accept header to the cache key of the CloudFront policy, otherwise a single version will be cached for all browsers.

Plesk

Versions Plesk Obsidian 18.0 for Linux.

On Plesk for Linux, Nginx often serves static files itself, before Apache: .htaccess rules then do not apply to images. In Websites & Domains > your domain > Apache & nginx Settings, check the “Serve static files directly by nginx” option: remove jpg, jpeg and png from the list so that Apache negotiation works, or prefer <picture> and a CMS plugin.

Shared hosting

On Apache or LiteSpeed hosting (OVHcloud, o2switch, Ionos, Hostinger, most cPanel plans), the block from the Apache section works in .htaccess. Conversion happens before uploading the files or through a CMS plugin; if the server's image library does not support AVIF, stick with WebP.

WordPress

Versions WordPress 6.5 and later; Modern Image Formats plugin 2 (WordPress 6.9 and later).

WordPress accepts WebP uploads since version 5.8 and AVIF since 6.5, if the server's image library supports them. Check this in Tools > Site Health > Info > Media Handling.

To convert uploaded JPEGs automatically, there are three options:

  • Modern Image Formats plugin from the WordPress Performance Team: it generates intermediate sizes as AVIF (or WebP if AVIF is not available), with a fallback option in Settings > Media and a <picture> element option. It only handles new uploads: regenerate thumbnails for existing images (wp media regenerate).
  • Custom filter, without a plugin: intermediate sizes are produced as AVIF, the original is kept.
add_filter('image_editor_output_format', function (array $formats): array {
    $formats['image/jpeg'] = 'image/avif';

    return $formats;
});

Shopify

Versions Online Store 2.0 themes, Liquid, all Shopify plans, November 2026.

Automatic. Shopify's CDN detects the formats the browser accepts (WebP, AVIF) and picks the most suitable one, provided the image is requested through the image_url filter. This filter's format parameter only accepts jpg and pjpg: do not use it, except to force JPEG in a specific case.

PrestaShop

Versions PrestaShop 1.7 to 9.

PrestaShop 8.1 to 9

PrestaShop itself generates the AVIF and WebP versions of each image type:

  1. On PrestaShop 8.1 and 8.2 only, first enable the “Multiple image formats” feature in Advanced Parameters > New & Experimental Features: it is disabled by default. On PrestaShop 9, the option is available directly.
  2. In Design > Image Settings, check AVIF and WebP among the formats to generate, then save.
  3. At the bottom of the same page, regenerate thumbnails to convert existing images.

The Classic theme of these versions already offers the generated formats in a <picture> element, with JPEG as the fallback; so does Hummingbird. An older third-party theme must be adapted in the same way.

PrestaShop 8.0 and 1.7

The core only generates JPEG or PNG. Use a conversion module, which rewrites URLs or modifies templates, or a CDN that converts images on the fly.

Magento

Versions Magento Open Source and Adobe Commerce 2.4.

Magento Open Source does not convert catalog images to WebP or AVIF by itself: use a converting CDN or a module. On Adobe Commerce on cloud infrastructure, Fastly image optimization can handle it, depending on your contract.

Drupal

Versions Drupal 10 and 11 (AVIF from Drupal 11.2).

In Configuration > Media > Image styles, add the “Convert” effect to each style with the webp extension, or avif from Drupal 11.2 if PHP's GD library can encode that format (the site's status report flags it otherwise). The core Responsive Image module then produces a <picture> element from these styles.

Wix

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

Automatic: the platform converts images and serves them in a format suited to the browser. Squarespace also optimizes images on delivery. There is nothing to configure; upload good-quality originals.

Webflow

Versions Webflow Designer, all plans, November 2026.

In the Assets panel, select the images and run the conversion offered (WebP, or even AVIF depending on your account). Keep social sharing images as JPEG or PNG.

Laravel

Versions Laravel 11 to 13, Intervention Image 3 and 4.

Generate the variants on upload with Intervention Image. The API changed between versions 3 and 4: check the installed version with composer show intervention/image. Run this processing in a queued job: AVIF encoding is slow.

Intervention Image 4

use Intervention\Image\Drivers\Gd\Driver;
use Intervention\Image\ImageManager;

$manager = ImageManager::usingDriver(Driver::class);

$image = $manager->decodePath(storage_path('app/public/images/atelier.jpg'))->scaleDown(width: 1600);

$image->save(storage_path('app/public/images/atelier.avif'), quality: 60);
$image->save(storage_path('app/public/images/atelier.webp'), quality: 80);

The destination file's extension determines the format: version 3's read(), toAvif() and toWebp() are replaced by decode…() and save() or encodeUsingFormat().

Intervention Image 3

use Intervention\Image\Drivers\Gd\Driver;
use Intervention\Image\ImageManager;

$manager = new ImageManager(new Driver());

$image = $manager->read(storage_path('app/public/images/atelier.jpg'))->scaleDown(width: 1600);

$image->toAvif(60)->save(storage_path('app/public/images/atelier.avif'));
$image->toWebp(80)->save(storage_path('app/public/images/atelier.webp'));

Next.js

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

next/image chooses the format from the Accept header. By default, it only produces WebP; add AVIF in next.config.js:

module.exports = {
  images: {
    formats: ['image/avif', 'image/webp'],
  },
};

Order matters: the first format accepted by the browser is served. With a static export (output: 'export'), the optimizer is not available: generate the formats at build time.

Nuxt

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

With Nuxt Image, NuxtPicture produces a <picture> element with several formats:

<NuxtPicture src="/images/atelier.jpg" format="avif,webp" width="800" height="533"
             alt="TIG welding station in the workshop" loading="lazy" />

Astro

Versions Astro 5 to 7.

The Image component produces WebP by default. To offer AVIF with a fallback, use Picture:

---
import { Picture } from 'astro:assets';
import atelier from '../assets/atelier.jpg';
---
<Picture src={atelier} formats={['avif', 'webp']} alt="TIG welding station in the workshop" />

Common mistakes

  • Removing the JPEG fallback: <picture> without a valid <img src>, or src pointing to an AVIF, and some crawlers or older browsers no longer get an image.
  • Negotiating at the origin behind a CDN that ignores Vary: Accept: a browser receives a format it cannot read.
  • Switching the logo or diagrams to WebP when an SVG would be lighter and sharper.
  • Making the og:image an AVIF: the sharing preview may not display on some platforms.
  • Sending AVIF files in the Merchant Center feed: the format is not accepted.
  • Stacking a conversion plugin, Polish and server negotiation: three conversions, images recompressed twice and conflicting Vary headers.

Frequently asked questions

WebP or AVIF: which one should I choose?

Both, with a JPEG fallback. AVIF generally compresses better than WebP, at the cost of slower encoding; WebP remains an excellent second choice. With a picture element, the browser takes the first format it can read. If you can only generate one, WebP is the simplest to produce, and almost every CMS, CDN and conversion tool supports it.

Does Google index WebP and AVIF images?

Yes. Google Search indexes BMP, GIF, JPEG, PNG, WebP, SVG and AVIF images referenced in the src attribute of an img element. It asks that the file extension match its real format, and points out that some crawlers do not read picture or srcset: always keep a src attribute that points to a valid image, preferably a JPEG for the fallback.

Should the og:image be converted to WebP?

No, keep it as JPEG or PNG. The social network and messaging platforms that generate link previews do not all support recent formats in the same way, and a preview without an image costs clicks. The weight savings are pointless here: this image is not displayed in the page, it is only downloaded by sharing platforms.

My site is on Shopify or Wix: do I need to convert my images?

No. Shopify and Wix convert images themselves and serve them in the format best suited to the browser. On Shopify, all you need to do is request images through the image_url filter in the theme, without forcing a format. Your job is to upload good-quality originals at the right dimensions and to fill in the alt text.

Updated on

Topic checklist (PDF)

And now?

In the “Images and multimodal search” topic

  1. Use descriptive file names
  2. Write relevant ALT text without keyword stuffing
  3. Use WebP/AVIF if appropriate
  4. Compress images
  5. Size images appropriately
  6. Use srcset and sizes
  7. Set width/height
  8. Lazy-load offscreen images
  9. Optimize key images
  10. Add captions if relevant
  11. Use original images
  12. Provide textual context
  13. Allow crawler access
  14. Create an image sitemap if needed
  15. Fix broken images
  16. Check rights and credits
  17. Measure Google Images visibility
  18. Test multimodal searches