Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared Managed Cloud India
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Best lists Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Speed & performance · Guide

How to Serve WebP and AVIF Images in WordPress

Short answer

To serve WebP and AVIF images in WordPress, first check server support under Tools, Site Health, Info, Media Handling. Then install the Modern Image Formats plugin or an image plugin such as ShortPixel, choose WebP or AVIF under its settings, and convert the images already in your Media Library. Finally, check delivery in your browser DevTools Network tab.

Key takeaways

  • WordPress has accepted WebP uploads since version 5.8 and AVIF uploads since version 6.5, when the server library supports them.
  • WordPress does not convert JPEG or PNG uploads to WebP or AVIF by itself, so a plugin or a filter is needed for conversion.
  • The Modern Image Formats plugin converts new uploads only, and old images need regeneration to get modern copies.
  • Lossy WebP files are 25 to 34 percent smaller than comparable JPEG files at the same quality, based on Google's published study.
  • WebP and AVIF need a fallback for older browsers, either through the picture element or through server and CDN format checks.
  • Check delivery in DevTools by looking at the Type column in the Network tab after reloading the page.

What does serving WebP and AVIF in WordPress mean?

Serving WebP and AVIF in WordPress means delivering your photos and graphics in those two newer formats instead of JPEG or PNG when the visitor's browser can show them.

WebP is a modern image format from Google that supports lossy and lossless compression, transparency, and animation. Google for Developers states that lossy WebP images are 25 to 34 percent smaller than comparable JPEG images at the same quality, and lossless WebP images are 26 percent smaller than PNG images.

AVIF is based on the AV1 video codec. web.dev reports that savings compared with JPEG can exceed 50 percent in some cases, depending on the image, the encoding settings, and the quality target.

Serving means more than converting one file. WordPress must create the modern copy, store it, and send it to browsers that support it while sending JPEG or PNG to browsers that do not.

What do you need before you start?

You need a backup, a WordPress version that accepts the formats, and a server image library that can process them.

Start with a full backup of your site and your Media Library. Conversion creates new files and, on some setups, replaces files, so keep a copy you can restore.

WordPress has accepted WebP uploads since version 5.8. Developer.WordPress.org records that WebP support arrived in version 5.8.0 and AVIF support arrived in version 6.5.0.

Your server also matters. WordPress relies on the GD or Imagick library that ships with PHP, and that library must support the format you want. If it cannot write AVIF, no plugin that converts on your server can create AVIF files either.

Pick one conversion route before you begin. The table below shows the main routes covered in this guide.

RouteBest forNew uploadsOld library
Modern Image Formats pluginFree, on-server conversionYesOnly after regeneration
ShortPixelBulk conversion and delivery choicesYesYes, with bulk tool
LiteSpeed CacheSites already using LiteSpeed and QUIC.cloudYesYes, with image optimization
Cloudflare PolishSites already on CloudflareNo change on serverYes, from cache

How do you check whether your server supports WebP and AVIF?

Open Tools, Site Health, Info, Media Handling in your WordPress admin and look for WebP and AVIF in the supported formats list.

That screen lists what your server image library can handle. If AVIF is missing, your host library cannot process it, and you need a different route, such as a cloud converter or a CDN that converts images.

Also check your WordPress version under Dashboard, Updates. If you run a version older than 6.5, update before you plan an AVIF rollout, since AVIF uploads need version 6.5 or newer.

If the list shows WebP but not AVIF, start with WebP. You still get most of the saving, and you can add AVIF later when your host supports it.

How do you serve WebP and AVIF with the Modern Image Formats plugin?

Install the Modern Image Formats plugin, open Settings, Media, and choose your output format in the Modern Image Formats section.

This plugin comes from the WordPress Performance Team. WordPress.org states that it adds WebP and AVIF support for media uploads, and that AVIF is generated by default when the hosting server supports it, with WebP used otherwise.

Follow these steps:

  1. Go to Plugins, Add New, search for “Modern Image Formats”, then install and activate it.
  2. Go to Settings, Media, and find the “Modern Image Formats” section.
  3. Choose WebP or AVIF as the output format when both are available.
  4. Tick “Output fallback images” only if you want a copy in the original format as well as the modern copy for every sub-size.
  5. Upload a test JPEG or PNG and check the file type of the copies WordPress creates.

By default, only the sub-sizes are converted. The original uploaded file stays as JPEG or PNG, and the generated sizes become WebP or AVIF files.

The plugin converts new uploads only. Images already in your Media Library stay in their old format until you regenerate them, which the next section covers.

How do you convert the images already in your Media Library?

Regenerate your image sub-sizes with a plugin such as Regenerate Thumbnails or with the WP-CLI command wp media regenerate.

WordPress.org states that pre-existing images are converted to a modern format only if images are regenerated. That step is easy to miss, and it explains why many sites enable a plugin and see no change on old posts.

Before you regenerate, check your disk space. Regeneration creates a new set of files for every image, and a large library can grow while both old and new copies exist.

Run the job in small batches on a large site. Start with 20 or 50 images, check a few pages, then continue with the rest.

If you use a converter plugin instead, use its bulk tool. ShortPixel, for example, has a bulk screen under Media, Bulk ShortPixel, which processes the existing library after you set the format options.

How do you serve WebP and AVIF with ShortPixel?

Install ShortPixel Image Optimizer, open Settings, ShortPixel, WebP/AVIF and CDN, then turn on Create WebP Images and Create AVIF Images.

ShortPixel is a vendor plugin that converts images through its own service and offers several delivery methods. ShortPixel lists three delivery methods: using .htaccess rules, using its CDN, or using picture tags.

Follow these steps:

  1. Go to Plugins, Add New, search for “ShortPixel Image Optimizer”, then install and activate it.
  2. Add the API key the plugin asks for in its settings screen.
  3. Choose a compression type in Settings, ShortPixel: Lossy gives the smallest files, Glossy keeps more detail for photos, and Lossless keeps every pixel.
  4. Open Settings, ShortPixel, WebP/AVIF and CDN, and enable Create WebP Images and Create AVIF Images.
  5. Choose a delivery method, then save the settings.
  6. Go to Media, Bulk ShortPixel, and run bulk optimization on the existing library.

The .htaccess method works on Apache servers and leaves your HTML unchanged. The picture tag method works on all servers, since it wraps each image in a picture element with a fallback.

If your host runs Nginx, do not choose the .htaccess method. Use the CDN or picture tag method instead, since Nginx does not read .htaccess files.

For more detail on the plugin settings, read ShortPixel settings explained.

How do you serve WebP and AVIF with LiteSpeed Cache?

Connect LiteSpeed Cache to QUIC.cloud, open LiteSpeed Cache, Image Optimization, Image Optimization Settings, and set Next-Gen Image Format to WebP or AVIF.

LiteSpeed Cache sends images to QUIC.cloud for optimization and pulls the results back to your site. LiteSpeed states that version 7.0 of the plugin added a choice of AVIF as the next-generation image format, alongside WebP.

Follow these steps:

  1. Go to LiteSpeed Cache, General, and click Enable QUIC.cloud services.
  2. Go to LiteSpeed Cache, Image Optimization, Image Optimization Settings.
  3. Set Next-Gen Image Format to WebP or AVIF.
  4. Turn on Auto Request Cron so new uploads are sent for optimization.
  5. Go to the Image Optimization Summary tab and click Send Optimization Request.

WebP images can be generated with either the Standard Queue or the Advanced Queue. LiteSpeed states that AVIF images can be generated only with the Advanced Queue, and that QUIC.cloud gives every domain some free Advanced Queue quota each month.

Keep your original files. The plugin keeps the original as a backup, so you can switch back if a converted image looks wrong.

For the full setup, read how to set up LiteSpeed Cache with QUIC.cloud.

How do you serve WebP and AVIF through Cloudflare Polish?

Open the Cloudflare dashboard, go to Speed, Settings, Image Optimization, choose Lossy or Lossless under Polish, and turn on WebP.

Polish works on copies of your images in the Cloudflare cache. Your origin files stay unchanged, and later visitors get the smaller cached copy.

Cloudflare states that the WebP version is served only when the browser Accept header includes WebP and the WebP image is much smaller than the recompressed original. The AVIF version is served only when the Accept header includes AVIF and the AVIF image is much smaller, and when both are present, Polish serves AVIF.

Polish does not produce AVIF versions of animated images. That limit matters for animated GIF files you want to keep moving.

After you change Polish settings, purge the cache or wait for cached images to expire. Cloudflare states that images in the cache must be purged or expired before you see changes in Polish settings.

Use format=auto with Cloudflare image transformations if you want on-the-fly conversion to WebP or AVIF. That route is separate from Polish and handles resizing as well as format choice.

How do you serve WebP and AVIF with a picture element?

List an AVIF source first, then a WebP source, then a JPEG or PNG image inside a picture element, and the browser picks the first format it supports.

The picture element is the manual route. It suits hand-built templates and theme code where you control the markup, and it gives you a clear fallback for older browsers.

A basic pattern uses three parts in order: a source for the AVIF file, a source for the WebP file, and an img tag for the JPEG file.

The browser reads the sources in order. If it supports AVIF, it uses the AVIF file. If not, it tries WebP, and if that fails, it uses the JPEG in the img tag.

Keep the alt text, width, and height on the img tag. Those values apply whichever source the browser picks, and width and height help stop layout shift.

web.dev notes that modern formats such as WebP and AVIF may give better compression than PNG or JPEG, which makes the file smaller and faster to download. Use the picture element only where you need manual control, since plugins and CDNs handle this choice for most WordPress sites.

How do you check that WebP and AVIF are actually being served?

Open a page in Chrome, open DevTools, Network, filter by Img, reload the page, and look at the Type column for webp or avif.

That check takes less than a minute and shows what the browser really received. A plugin setting that says WebP is on does not prove the file reached the visitor.

Check these three things:

  • The Type column shows webp or avif for your photos, not jpeg or png.
  • The Size column is smaller than the old JPEG or PNG file for the same image.
  • The image still looks right at full size, with no banding, blur, or missing transparency.

Also run PageSpeed Insights on the page. Its “Serve images in next-gen formats” audit flags images that are still served as JPEG or PNG when a modern format would save bytes.

If the Type column still shows jpeg, clear your page cache and CDN cache, then reload. Cached pages and cached images often hide a new setting until the cache clears.

Smaller images help the largest image on the page load sooner. For the wider speed work around that, read how to pass Core Web Vitals in WordPress.

What mistakes should you avoid?

Do not enable two converters at once, do not skip the old library, and do not judge the result from one image.

Running two image plugins that both convert formats can double-process images and break delivery. Pick one route, turn the other off, and check the result before you change anything else.

Converting only new uploads is the most common miss. If your old posts still show JPEG files, run the bulk or regeneration step in the earlier section.

Do not convert a logo or a line drawing with lossy settings and expect it to stay sharp. Use lossless WebP or keep PNG for flat graphics with sharp edges and text.

Do not remove the original files until you have checked the converted images. Keep the backup until you are sure the new files look right on desktop and on a phone.

Finally, remember that format is only one part of image speed. Oversized images still waste bytes even in AVIF, so check your image sizes too. For that work, read how to avoid enormous network payloads in WordPress.

Frequently asked questions

Does WordPress convert JPEG images to WebP by itself?

No. WordPress accepts WebP uploads since version 5.8 and AVIF uploads since version 6.5, but it does not convert JPEG or PNG uploads to a modern format on its own. You need a plugin such as Modern Image Formats, a converter plugin, a CDN, or the image_editor_output_format filter to create the modern copies.

Do I need AVIF if I already serve WebP?

No, WebP alone is a good result for most sites. AVIF can save more bytes on photos, but it encodes more slowly and needs server support. Add AVIF only after WebP works, your host supports it, and you have checked that the converted files look right.

Will older browsers still see my images?

Yes, if you keep a fallback. The picture element falls back to the JPEG or PNG in the img tag, and plugins and CDNs check the browser Accept header before serving a modern format. Do not delete the original files until you have confirmed the fallback works.

How long does it take to convert a whole Media Library?

It depends on the number of images, their size, and the route you use. A small library of under 100 images often finishes in minutes. A library with thousands of large photos can take hours, so run it in batches and check a few pages between batches.

Does serving WebP or AVIF change my image URLs?

It depends on the route. On-server plugins usually keep the same URL and serve the modern file behind it, or use a picture element with the same page markup. CDN routes may change the delivered URL. Check a live page in DevTools rather than guessing from the settings screen.

Sources

  1. Modern Image Formats WordPress.org
  2. wp_getimagesize() WordPress Developer Resources
  3. Image performance web.dev
  4. Using AVIF to compress images on your site web.dev
  5. An image format for the Web Google for Developers
  6. Polish compression Cloudflare Docs
  7. AVIF Support in LiteSpeed Plugin v7 LiteSpeed Blog
  8. JPG to WebP: Why Converting Your Images Is a Smart Move ShortPixel

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

WPLegible editors

Researched from the primary sources listed above and checked against our editorial rules. About the site · How we test