To serve WebP and AVIF in WordPress, first confirm your server supports them (Tools > Site Health > Info > Media Handling), then choose one of four routes: upload WebP or AVIF files directly, convert new JPEG uploads automatically with a small code filter, convert your existing library with a plugin, or let a CDN choose the format for each visitor. WordPress has accepted WebP since version 5.8 and AVIF since 6.5.
Key takeaways
- Core support depends on your server's image library, not just your WordPress version.
- Uploading WebP or AVIF directly works for new images but does nothing for old ones.
- Converting an existing library needs a tool that updates links and thumbnails, not just new files.
- AVIF has slightly less browser support than WebP, so decide how you'll handle the rest.
Step 1: Check what your server supports
WordPress uses Imagick or GD to create its resized copies. The WordPress core team's AVIF note says AVIF works "as long as your hosting environment supports AVIF", and the WebP note says the same for WebP.
To check, go to Tools > Site Health > Info > Media Handling and look for WebP and AVIF in the supported formats. If AVIF is missing, ask your host whether their image library can support it.
Route 1: Upload WebP or AVIF files directly
The simplest option. Convert photos before upload (with an image editor, a command-line tool or an online converter) and upload the .webp or .avif file. WordPress creates its usual thumbnail sizes in the same format.
Good for: new posts and pages. Limit: does nothing for images already in the library, and you need a conversion step in your routine.
Route 2: Convert new JPEG uploads with a filter
WordPress has a filter, image_editor_output_format, that changes the format of the resized copies it generates. The AVIF developer note gives this function; the add_filter line hooks it in:
```php
// Output AVIFs for uploaded JPEGs
function filter_image_editor_output_format( $formats ) {
$formats['image/jpeg'] = 'image/avif';
return $formats;
}
add_filter( 'image_editor_output_format', 'filter_image_editor_output_format' );
```
Put it in a small custom plugin or your child theme's functions.php. Quality is controlled by another filter, wp_editor_set_quality; the note says AVIF output is lossy at quality 82 by default.
Good for: developers who want new uploads converted without a plugin. Limits: applies to new uploads only, and it changes the generated sizes, so test that your theme displays them as expected.
Route 3: Convert your existing library with a plugin
This is the route most sites need, because years of JPEGs are already in posts. A conversion plugin should:
- Convert each image and regenerate every thumbnail size.
- Update references in post content, post meta, widgets and theme settings, or serve the new format without changing URLs.
- Redirect old URLs if file extensions change.
- Keep the originals and let you revert.
- Skip images that were already converted.
Plugins differ in where encoding happens (on your server or in the cloud), whether they replace files or add copies, and whether they serve the new format through rewrite rules, picture tags or a CDN. Read the documentation for how a plugin delivers the files before you install it.
Route 4: Let a CDN pick the format
Some CDNs and image services convert on the fly and send AVIF or WebP only to browsers that accept it, keeping your originals untouched. Shopify does this for its stores, for example: its help center says its image service picks the best format the visitor's browser supports.
Good for: large sites, sites with many visitors on older browsers. Limits: an extra service to configure and pay for, and the originals in your library stay large.
What about browsers that don't support AVIF?
Caniuse reports about 96% global support for AVIF and about 97% for WebP (October 2026). MDN recommends a fallback when using AVIF, typically a picture element with a JPEG or WebP source. WordPress's own note suggests that sites with significant traffic from unsupported browsers either avoid AVIF or use a polyfill.
If you upload AVIF directly with no fallback, a small share of visitors on older Safari or Edge versions may not see the image. Check your analytics for browser versions before deciding.
How to check it worked
After converting, confirm visitors actually receive the new format:
- Open a page in Chrome or Firefox and open the developer tools (F12).
- Go to the Network tab, filter by Img and reload the page.
- Click an image request and check the Content-Type response header:
image/aviforimage/webpmeans it worked. - Compare the transferred size with the old file.
- Repeat on a phone, and if you can, in an older Safari version, to see what your fallback serves.
If the Content-Type is still image/jpeg, the plugin or CDN may be serving the original, or a page cache may be holding old HTML. Clear caches and test again.
WebP or AVIF?
In our test of 54 business photos at the same preset and size, the AVIF total was 39.2% smaller than the WebP total and smaller for every photo. WebP was only 1.5% smaller than JPEG in total at those settings. So for photo-heavy sites, AVIF is usually worth the extra care.
Converting an existing library with our plugin
The Picture Optimizer WordPress plugin (Pro and up, $49 a month with a 7-day trial) converts images already in your Media Library to WebP or AVIF on our servers, replaces each original, regenerates thumbnails, updates every URL with redirects for the old ones, and can revert any image. On Starter, you can convert photos in the tool and send them to your Media Library instead. The WordPress image optimization page covers the whole workflow.
Keep reading
- How to optimize images in WordPress (without breaking old posts)
- ShortPixel vs Imagify vs Smush: which WordPress optimizer fits your site?
Sources
- make.wordpress.org/core/2021/06/07/wordpress-5-8-adds-webp-support
- make.wordpress.org/core/2024/02/23/wordpress-6-5-adds-avif-support
- caniuse.com/avif
- caniuse.com/webp
- developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Image_types
- help.shopify.com/en/manual/products/product-media/product-media-types
Questions
Short answers to what people ask about this.