WebP + AVIF converter

Description

Fast, simple & free plugin to automatically convert and serve WebP & AVIF images.

Features

  • Automatically convert and serve WebP/AVIF images.
  • Increase your Google Pagespeed.
  • Only images which are really used will be converted, does not convert the whole media library.
  • WebP/AVIF quality is adjustable (default 100% = no quality loss)
  • No image URLs are changed, solution is purely based on .htaccess rewrite rules.
  • Serve original format in case the browser does not support WebP/AVIF (relying on the “Accept” header).
  • The following source formats are supported: JP(E)G, PNG, GIF, BMP.
  • Extra feature: WebP images are served as PNG when the browser/client does not support WebP (e.g. Microsoft Outlook).

Browser support

  • WebP: all modern browsers
  • AVIF: Chrome, Firefox, Safari (Edge doesn’t support AVIF yet)

Good to know

  • It may take a few minutes before the WebP/AVIF images are generated after activating the plugin.
  • AVIF is a relatively new format, and not widely supported yet on servers. This depends on your server configuration (see Server requirements).
  • Generating AVIF images is CPU-intensive, and may take a while.
  • WebP/AVIF format is only served when this format is smaller than the original file. Depending on the image, WebP/AVIF is not always the most efficient format.
  • Animated GIF-images are not supported yet as GDlib/ImageMagick don’t have support for it

How the plugin works

The plugin does nothing until the first image is requested. Here is the conversion flow.

  1. Original image is requested in browser
  2. Image is added to the conversion queue, original image is still served.
  3. Conversion queue is processed in background, queued images are converted to WebP/AVIF format.
  4. When the image is requested now, and the browser supports WebP and/or AVIF, the WebP/AVIF image is served.

Screenshots

  • Settings page
  • PageSpeed Insights

Installation

Server requirements

  • Apache 2.x with mod_rewrite or Nginx
  • ImageMagick or GDlib with WebP support
  • ImageMagick or GDlib with AVIF support (optional)
    • You can use this plugin without AVIF support, in that case only WebP conversion is done

Installation (Apache)

The .htaccess rules are applied automatically when activating the plugin. Install the plugin and go!

Installation (Nginx)

You have to add the following lines to your nginx configuration:
In the http section (outside the server section):

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

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

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

In the server section, above the “location /” rule:
(Change the wp-content part if this folder is in a non-standard location.)

location ~* wp\-content/(?!cache/fastware\-webpavif).+\.(jpe?g|png|gif|bmp|webp)$ {
    if (!-f $request_filename) {
        break;
    }
    rewrite /wp\-content/(.+)$ /wp-content/cache/fastware-webpavif/$1;
}

location ~* cache/fastware\-webpavif.+\.(jpe?g|png|gif|bmp)$ {
    add_header Vary Accept;
    expires 30d;
    try_files $uri.pref$webp $uri.pref$avif $uri$webp $uri$avif $uri /?fw-webp-avif-ondemand=all;
}

location ~* cache/fastware\-webpavif.+\.webp$ {
    add_header Vary Accept;
    expires 30d;
    try_files $uri$png /?fw-webp-avif-ondemand=png;
}

If there exist a rule for images like location ~* ^.+.(ogg|…|jpg|jpeg|gif|png|webp|ico|bmp|…)$:

Please remove the following matching extensions: jpg|jpeg|gif|bmp|webp|avif.

In the mime.types file, make sure the following lines are present:

image/webp                                       webp;
image/avif                                       avif;

FAQ

How can I verify the plugin is working?

Please check the settings page to verify your server meets the installation requirements.

How can I serve my images even smaller?

You can lower the quality settings on the settings page to serve smaller images. A value of 85% might be a good balance between quality and image size.

Why is the original image served sometimes?

It could happen that your original image is smaller than the converted WebP/AVIF image – in that case, the original image is served.

How long would it take to convert all images on my site?

That depends. Each image is queued upon the first request. After the first request the image should be converted within a few minutes (depending on when the cron runs).
When your site contains a lot (thousands) of images, it can take a few hours before all images are converted.

Reviews

December 8, 2023
Caused hundreds of my site's images to display as blank. Uninstalled.NOTE TO MODERATOR: THIS IS A REVIEW, NOT A SUPPORT REQUEST. I AM NOT SEEKING FOR SUPPORT OR ANSWERS, SINCE I AM NO LONGER USING THIS PLUGIN. I AM REPORTING MY EXPERIENCE WITH IT FOR BENEFIT OF PEOPLE CONSIDERING TRYING IT OUT. IN OTHER WORDS, A "REVIEW", NOT A "SUPPORT REQUEST".
October 23, 2023
This plugin does not work and as I understand that there are no responses from support, it is logical that the author no longer supports it
July 1, 2023
Been using the Converter for Media plugin by Matt before - but that requires a premium version for avif support - and creates a huge mess of files in your uploads directory by downsizing all images. Now maybe that's a good idea - but not in the main folder because backups get huge. This plugin is doing just what it's supposed to do, and cleanly puts all files into the cache directory.
May 3, 2023
This plugin works. It is able to convert and serve images in webp and avif format, without overloading the server. It does the conversion the first time an image is served, and then offers the webp or avif format, depending on the browser. Tested on a Nginx server. Easy to configure on Nginx and out of the box with apache. Thank you
Read all 8 reviews

Contributors & Developers

“WebP + AVIF converter” is open source software. The following people have contributed to this plugin.

Contributors

“WebP + AVIF converter” has been translated into 3 locales. Thank you to the translators for their contributions.

Translate “WebP + AVIF converter” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Changelog

Releases

  • 2.0.7 [03-07-2023] Fixed redirect loop
  • 2.0.6 [13-05-2023] Fixed issue with background converts
  • 2.0.5 [06-05-2023] Added support for GDlib AVIF conversion (PHP >= 8.1)
  • 2.0.4 [06-05-2023] Fixed error in loopback test on plugin configuration page
  • 2.0.3 [06-05-2023] Fixed error in loopback test on plugin configuration page
  • 2.0.2 [02-05-2023] More detailed checks/errors on plugin configuration page
  • 2.0.1 [25-04-2023] Fix in wrong .htaccess rule
  • 2.0.0 [25-04-2023] Added support for nginx
  • 1.1.4 [07-04-2023] Fixed issue with rewriterules test
  • 1.1.3 [07-04-2023] Show statistics of converted/queued/skipped images
  • 1.1.2 [29-03-2023] Added support for converting GIF images
  • 1.1.1 [28-03-2023] Added support for converting BMP images
  • 1.1.0 [20-03-2023] Added WebP/AVIF quality settings
  • 1.0.8 [15-03-2023] .htaccess fix + minor change in plugin name
  • 1.0.7 [13-03-2023] Added admin dashboard to check plugin/server configuration
  • 1.0.6 [07-03-2023] Fixed redirect bug on servers without avif support
  • 1.0.5 [04-03-2023] Moved working directory, to improve cleanup after uninstall
  • 1.0.4 [27-02-2023] Added support for PHP 7.4, fixed issue with scheduled converts
  • 1.0.3 [22-02-2023] Adjust code to improve quality
  • 1.0.2 [21-02-2023] Bugfix in GD convert
  • 1.0.1 [18-02-2023] Stricter typing & ImageMagick as primary converter with GD as fallback
  • 1.0.0 [17-02-2023] Initial version