Features Pricing Reviews FAQ
Get Plugin

Image Conversion to WebP and AVIF

5 min read

WebP and AVIF are modern image formats that are usually much smaller than JPEG or PNG at the same visual quality. xSpeed Cache Pro can convert your uploads to these formats and serve them to browsers that support them.

What this does

When image conversion is on, xSpeed Cache Pro converts every new JPEG and PNG you upload to the media library into a WebP file, an AVIF file, or both. The converted files are saved next to the originals, including for the resized versions WordPress creates.

On the front end, xSpeed Cache Pro rewrites image tags so that browsers which accept WebP or AVIF receive the smaller file. Browsers that do not are served the original.

Note: Only JPEG and PNG uploads are converted. Other files (existing WebP or AVIF, GIF, SVG, PDF) are left unchanged.

Why use it

Smaller image files mean less to download, which speeds up page loads and saves bandwidth. Because the original is kept and only sent when a browser cannot handle the newer format, you get the size savings without breaking older browsers.

Requirements

  • xSpeed Cache Pro must be installed and active. Image conversion is a Pro feature.
  • The host must support the format you want. xSpeed Cache Pro uses the server’s Imagick or GD library to do the conversion. A format can only be produced if one of those libraries supports it on your server.

Tip: xSpeed Cache Pro can report which engines and formats your server supports. WP-CLI users can run wp xspeed images caps to see Imagick and GD availability for WebP and AVIF.

How conversion happens

Conversion runs automatically when a new image finishes uploading. xSpeed Cache Pro converts the full-size image and each intermediate size WordPress generated. The new files are saved alongside the originals with the same name and a .webp or .avif extension.

Conversion is idempotent: if a converted file already exists, xSpeed Cache Pro does not redo it.

Important: Automatic conversion only runs on images you upload after turning the feature on. Images that were already in your media library are not converted in bulk, and there is no “convert existing images” button. To convert an existing file, WP-CLI users can run wp xspeed images convert --file=<path> one file at a time (add --format=avif to target AVIF; the default is WebP).

How serving happens

On the front end, xSpeed Cache Pro looks at the browser’s Accept header to decide what the browser supports. It then rewrites the src and srcset of images to point at the smaller sibling, but only when that sibling file actually exists on disk. If it does not, the original is served.

When both formats are enabled and the browser accepts both, AVIF is preferred over WebP.

How to set it up

  1. Go to the xSpeed Cache settings and open the Image Optimization panel.
  2. Turn on Convert to WebP, Convert to AVIF, or both.
  3. Adjust the quality settings if needed (defaults are fine for most sites).
  4. Save your changes.
  5. Upload a new image and confirm the smaller format is being served.

Settings explained

SettingWhat it doesDefault
Convert to WebPGenerates a .webp version of each JPEG/PNG upload and serves it to browsers that accept WebPOn
Convert to AVIFAlso generates a .avif version and serves it to browsers that accept AVIFOff
WebP qualityCompression quality for WebP files (30–100)82
AVIF qualityCompression quality for AVIF files (20–100)60

Convert to WebP. Creates a WebP file for every JPEG and PNG you upload. WebP is supported by all major browsers released since 2020.

Convert to AVIF. Also creates an AVIF file. AVIF is typically smaller than WebP at the same quality, but it takes longer to encode and support is not yet as universal.

WebP quality. Controls the trade-off between file size and image quality for WebP, on a scale of 30 to 100. The default of 82 matches the WordPress core JPEG default. Lower values produce smaller files with more visible compression.

AVIF quality. Controls the same trade-off for AVIF, on a scale of 20 to 100. The default of 60 is set lower than the WebP default because AVIF is more efficient. At 60, AVIF looks roughly equivalent to WebP at 82.

Best practices

  • Start with WebP only. It is widely supported and gives most of the savings with the least encoding cost.
  • Turn on AVIF as well if your site is photo-heavy and your server supports AVIF encoding. Confirm support first with the capabilities check.
  • Leave the quality settings at their defaults unless you see quality problems (raise them) or want smaller files (lower them).
  • After enabling, upload a test image and view a page in a current browser to confirm the smaller format is served.

Troubleshooting

No WebP or AVIF files are being created. Your server may not support that format in Imagick or GD. Check the capabilities report. If a format shows as unavailable, ask your host to enable WebP or AVIF support in the image library.

Images are still served as JPEG or PNG. This is expected when the browser does not send an Accept header for the newer format, or when the converted sibling file does not exist for that image. Older images may not have been converted; only new uploads are converted automatically.

AVIF uploads are slow. AVIF encoding is more demanding than WebP. If uploads feel slow and you do not need AVIF, turn it off and keep WebP.

FAQ

Are my original images deleted? No. The converted files are saved next to the originals, and the original is still served to browsers that cannot use the newer format.

Which format is served when both are enabled? If the browser accepts both, AVIF is preferred. Otherwise WebP is used, and if neither is accepted, the original is served.

  • Removing Unused CSS
  • Generating Critical CSS
  • CDN Integration