Fork me on GitHub
X

WordPress-kehittäjä, älä missaa ilmaista webinaariamme WordPressin hakutoiminnosta tammikuun 14. päivä!

WordPress-utvecklare, missa inte vår gratis webbinar om sökningen in WordPress den 14. januari!

WordPress developer, don't miss our free webinar about search in WordPress on January 14th!

One way to serve images in WebP format is by using the WebP Converter for Media plugin.

In addition to installing and activating the plugin some additional configuration for NGINX is required.

Create a file webp.conf inside the folder /data/wordpress/nginx and copy this configuration inside it:

# NGINX config for WebP Converter for media
# https://wordpress.org/plugins/webp-converter-for-media/
location ~ /wp-content/(?<path>.+)\.(?<ext>jpe?g|png|gif)$ {
  if ($http_accept !~* "image/webp") {
    break;
  }
  add_header Vary Accept;
  expires 365d;
  try_files /wp-content/uploads-webpc/$path.$ext.webp $uri =404;
}

REMEMBER! NGINX has to be restarted after adding a config file. Run command wp-restart-nginx to restart.

You can now continue with the plugin setup.