Images to WebP


Statistics say that WebP format can save over a half of the page weight without losing images quality.
Convert PNG, JPG and GIF images to WebP and speed up your web, save visitors download data, make your Google ranking better.

  • automated test after plugin activation to make sure it will work on your server
  • works with all types of WordPress installations: domain, subdomain, subdirectory, multisite/network
  • works on Apache and NGiNX
  • image URL will be not changed so it works everywhere, in <img> src, srcset, <picture>, even in CSS backgrounds and there is no problem with cache
  • original files will be not touched
  • set quality of converted images
  • auto convert on upload
  • only convert image if WebP filesize is lower than original image filesize
  • bulk convert existing images inside /wp-content/ folders to WebP ( you can choose folders )
  • bulk convert only missing images
  • works with `Fly Dynamic Image Resizer` plugin

Hooks for developers


Maybe you want to support also less famous JPEG extension like jpe, jfif or jif

add_filter( 'itw_extensions', 'extra_itw_extensions', 10, 1 );
function extra_itw_extensions( $extensions ){
    $extensions[] = 'jpe';
    $extensions[] = 'jfif';
    $extensions[] = 'jif';
    return $extensions;


Maybe you want to disable WebP for thumbnails

add_filter( 'itw_sizes', 'disable_itw_sizes', 10, 2 );
function disable_itw_sizes( $sizes, $attachmentId ){
    unset( $sizes['thumbnail'] );
    return $sizes;


Maybe you want to modify htaccess rules somehow

add_filter( 'itw_htaccess', 'modify_itw_htaccess', 10, 2 );
function modify_itw_htaccess( $rewrite_rules ){
    // do some magic here
    return $rewrite_rules;


Maybe you want to disable/enable some other folders for bulk convert

add_filter( 'iwt_disabled_folders', 'modify_iwt_disabled_folders', 10, 1 );
function modify_iwt_disabled_folders( $disabled ){
    // do some magic here
    return $disabled;


Maybe you want to automatically generate WebP for other plugins

add_action( 'XXPLUGIN_image_created', 'XX_images_to_webp', 10, 2 );
function XX_images_to_webp( $image_path ){
    global $images_to_webp;
    $images_to_webp->convert_image( $image_path );



  1. Upload images-to-webp directory to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress


Plugin requirements

It should work almost everywhere 😉
PHP 5.6 or higher
GD or Imagick extension with WebP support
Enabled serve modules: mod_mime, mod_rewrite

WebP images stored location

WebP images are generated in same directory as original image. Example:
original img: /wp-content/uploads/2019/11/car.png
webp version: /wp-content/uploads/2019/11/car.png.webp

How to check if plugin works?

When you have installed plugin and converted all images, follow these steps:

  1. Run Google Chrome and enable Dev Tools (F12).
  2. Go to the Network tab click on Disable cache and select filtering for Img (Images).
  3. Refresh your website page.
  4. Check list of loaded images. Note Type column.
  5. If value of webp is there, then everything works fine.

Apache .htaccess

Plugin should automatically update your .htaccess with needed rules.
In case it’s not possible to write them automatically, screen with instructions will appear.
Anyway, here is how it should look like:

<IfModule mod_mime.c>
    AddType image/webp .webp

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_ACCEPT} image/webp
    RewriteCond %{REQUEST_FILENAME} "/wp-content/"
    RewriteCond %{REQUEST_FILENAME} "\.(jpg|jpeg|png|gif)$"
    RewriteCond %{REQUEST_FILENAME}\.webp -f
    RewriteRule ^(.+)$ $1\.webp [NC,T=image/webp,E=webp,L]

NGiNX config

After you activate plugin, screen with instructions will appear.
Anyway, here is how it should look like:

You need to add this map directive to your http config, usually nginx.conf ( inside of the http{} section ):

map $http_accept $webp_suffix{
    default "";
    "~*webp" ".webp";

then you need to add this to your server block, usually site.conf or /nginx/sites-enabled/default ( inside of the server{} section ):

location ~* ^/wp-content/.+\.(png|gif|jpe?g)$ {
    add_header Vary Accept;
    try_files $uri$webp_suffix $uri =404;


If you want to use this plugin, then you have to know a little about programming, because many errors occur during the plugin operation, and the plugin developer does not take any part in fixing them. It is quite obvious that the very name of the plugin implies that it is enough to download and install the plugin for it to work. But you can't do that with this plugin.
NEW REVIEW: Works like charm rn, developer is nice and really helpful. Big thumbsup. OLD REVIEW: Doesn't load WebP and doesn't show them in the media library. Seems to be converting just fine and going to the URL (imgurlblabla.png.webp) seems to be working too. Just doesn't load WebP.
Плагин отличный! Сначала не активировался пока не убрал в настройках хостинга из "статических файлов" форматы картинок - jpg,jpeg,png,gif,webp. После этого все активировалось! Многое зависит от хостинга, но с чем столкнулся когда убрал их из статики - пришлось потом вручную добавить правила кеширования для них: ExpiresActive On #кэшировать изображения на год: (Чтобы не ругался pagespeed гугла) ExpiresByType image/x-icon "access plus 365 days" ExpiresByType image/jpeg "access plus 365 days" ExpiresByType image/png "access plus 365 days" ExpiresByType image/gif "access plus 365 days" ExpiresByType image/webp "access plus 365 days"
Nginx config file doesn't allow location block to be inserted directly, i have to put inside a server block. The test is successful but i can't activate the plugin as it always redirects me to the 'instruction' page where it says to copy those few lines in the config files. I checked the code and it is because the code is basically "if the server is nginx wp_die" and the plugin dies there showing the information page only, without activating.


Images to WebP はオープンソースソフトウェアです。以下の人々がこのプラグインに貢献しています。


“Images to WebP” は3ロケールに翻訳されています。 翻訳者のみなさん、翻訳へのご協力ありがとうございます。

“Images to WebP” をあなたの言語に翻訳しましょう。

開発に興味がありますか ?

コードを閲覧するか、SVN リポジトリをチェックするか、開発ログRSS で購読してみてください。



  • Tested on WP 5.8
  • added some nonce checks and more security validations
  • better nginx instructions


  • Tested on WP 5.7
  • add more CURL options
  • fix backslashes for localhosts


  • Tested on WP 5.6
  • fixed problem on some multisites


  • Tested on WP 5.4
  • added support for Fly Dynamic Image Resizer plugin


  • notice when test image is not accessible


  • new test method


  • fixed text domain for translations


  • added instructions for NGiNX


  • make it works in multisite and subdirectory installs


  • First version