If you’re using nginx but can’t use the “map” directive from the FAQ (like this person couldn’t), here’s some alternative code:
if ( $http_accept ~ "image/webp" ) {
set $webp .webp ;
}
location ~* (.*)\.(?:png|jpe?g|gif)$ {
if ( -f $document_root$1.webp ) {
set $webp serve$webp ;
}
if ( $webp = "serve.webp" ) {
return 301 '$1.webp';
}
}
I had also tried this code, which is more efficient, but unfortunately it didn’t work for me:
if ( $http_accept ~ "image/webp" ) {
set $webp '.webp' ;
set $type 'image/webp';
}
location ~* \.(png|jpe?g|gif)$ {
add_header Vary Accept;
add_header X-Type "static/known";
add_header Cache-Control "public, max-age=2592000";
add_header Vary "Accept-Encoding";
add_header Access-Control-Allow-Origin *;
add_header content-type $type;
default_type '$type';
try_files $uri$webp $uri =404;
}
]]>
The “Convert Existing Images” page is stuck showing “Loading all subdirectories…“.
It doesn’t seem to have generated any webp images, it’s just stuck here.
Another user said they had the same issue and fixed it, but didn’t say how – see here
]]>Hello,
Is it possible to exlude images based on user roles? We want to exclude images uploaded by admin. Our website has services for guest posting, for the same, we want to optimize images only for other users apart from admin. Is this possible?
]]>Hi, I’ve converted all the images, but I have around 1,000 posts saved. How can I update those posts to use the new webp images without having to do it manually?
]]>
After testing on my local server and it did well, today I’m trying to activate the plugin on staging server but it return error that unable to access the test.png follow below error message
Testing file?mywebsitedotcom/wp-content/plugins/images-to-webp/tests/test.png
?is not accessible, but returns HTTP response code?404
. Contact your hosting provider or developer.
Please suggest on this.
]]>How can i disable webp on certain pages? I need to disable webp for the feed page because… This news aggregator cannot work with this news format. Currently using nginx fpm
]]>Hello!
I don’t care about browsers that don’t support WEBP, so I just wanted to replace it and not interfere with any cache delivery.
I just need to convert and replace PNG and JPG with WEBP ensuring smooth compatibility with CloudFlare and the edge cache.
Is there such a possibility?
]]>When converting from PNG to WEBP, is the transparency layer preserved?
]]>hello,
I installed the image to webp plugin but webp images are not loaded
My sites are behind an nginx reverse proxy, I was getting a lot of
admin-ajax.php 502 Bad Gateway nginx
I noticed that:
2024/02/13 15:25:25 [warn] 196#196: *346692 upstream server temporarily disabled while reading response header from upstream, client: X.Y.W.Z, server: mysite.com, request: "POST /wp-admin/admin-ajax.php HTTP/2.0", upstream: "https://172.18.0.11:80/wp-admin/admin-ajax.php", host: "mysite.com", referrer: "https://mysite.com/wp-admin/upload.php?page=images-to-webp.php&tab=convert"
2024/02/13 15:25:25 [error] 196#196: *346692 upstream timed out (110: Operation timed out) while reading response header from upstream, client: X.Y.W.Z, server: mysite.com, request: "POST /wp-admin/admin-ajax.php HTTP/2.0", upstream: "https://172.18.0.11:80/wp-admin/admin-ajax.php", host: "mysite.com", referrer: "https://mysite.com/wp-admin/upload.php?page=images-to-webp.php&tab=convert"
mysite.com X.Y.W.Z - - [13/Feb/2024:15:25:25 +0000] "POST /wp-admin/admin-ajax.php HTTP/2.0" 504 562 "https://mysite.com/wp-admin/upload.php?page=images-to-webp.php&tab=convert" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
2024/02/13 15:25:25 [error] 196#196: *346692 no live upstreams while connecting to upstream, client: X.Y.W.Z, server: mysite.com, request: "POST /wp-admin/admin-ajax.php HTTP/2.0", upstream: "https://mysite.com/wp-admin/admin-ajax.php", host: "mysite.com", referrer: "https://mysite.com/wp-admin/upload.php?page=images-to-webp.php&tab=convert"
mysite.com X.Y.W.Z - - [13/Feb/2024:15:25:25 +0000] "POST /wp-admin/admin-ajax.php HTTP/2.0" 502 552 "https://mysite.com/wp-admin/upload.php?page=images-to-webp.php&tab=convert" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
Wondering if there’s a better way to code this in order to avoid the timeout.. a solution is to increase the nginx read timeout:
location / {
proxy_read_timeout 1800;
]]>
Hi,
I run wprocket cdn and I wonder if image to webp will work
]]>Just like one plugin to convert images to webp
Choice the quality
Same name with new extension
And delete and replace the original in the posts
That will be great, at least as option
]]>It appears when running “Fine and convert Missing Images”, its triggering for all images to be regenerated. I tried this in chrome and edge and got the same results. The following javascript always returns zero even when the “convert-missing-images” was clicked . It appears “this” is the ajax call and not the sender.
convert_old_images( $(this).hasClass(‘convert-missing-images’) ? 1 : 0 );
]]>Dear Sir,
I′m doing some changes at website. I set a local server, to run tests.
I have installed images to webp, but i can′t activate.. This only happens here in local server…
Maybe you can give some help…
Message:
[13-Dec-2023 21:32:43 UTC] PHP Fatal error: Uncaught Error: Call to undefined function curl_init() in /var/www/html/obrasdarte.com/wp-content/plugins/images-to-webp/tests/configs.php:11
Stack trace: 0 /var/www/html/obrasdarte.com/wp-content/plugins/images-to-webp/images-to-webp.php(74): include_once() 1 /var/www/html/obrasdarte.com/wp-includes/class-wp-hook.php(324): images_to_webp->activate() 2 /var/www/html/obrasdarte.com/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() 3 /var/www/html/obrasdarte.com/wp-includes/plugin.php(517): WP_Hook->do_action() 4 /var/www/html/obrasdarte.com/wp-admin/includes/plugin.php(693): do_action() 5 /var/www/html/obrasdarte.com/wp-admin/plugins.php(58): activate_plugin() 6 {main}
thrown in /var/www/html/obrasdarte.com/wp-content/plugins/images-to-webp/tests/configs.php on line 11
Regards,
Tony
]]>Hello,
I have “Error 400 trying to continue with missing images” when I try to upload images to webp. I have already verified files permissions.
When the delete originals feature is in use the .htaccess rules make 404 errors because there is no original to fall back to.
The plugin should not have any criteria for substitution in the .htaccess when the originals are missing, as this can only make errors.
I can point out the two .htaccess lines to omit if needed?
Converting straight to WebP is a very risk-free way to save disk space because WebP supports everything that PNG/GIF and JPEG images support, with lossless options.
This is however not the most optimal way to get the smallest possible images and in reality you can stack layers of optimization utilities intelligently to get much better file sizes without a visible loss of quality.
There are other projects focused on the ‘best possible stack’ and some of them might even be open source/willing to share their secret recipes or willing to partner up as an upgraded module vs. just using a basic WebP conversion?
For example, I know that if you imagemagick convert util on PNG and sniff the output for ‘false’ you can confirm that it’s safe to run guetzli on the PNG making an optimized JPG prior to making the WebP result.
if convert "$file" -format "%[opaque]" info: | grep -q "false"; then
echo "$file has transparency"
else
echo "$file does not have transparency"
fi
Similarly if you want to test a .GIF for animation/transparency before using guetzli you can run gifsicle.
]]>inf=
gifsicle -I "$file"
if [inf | grep -q 'transparency'] || [inf | grep -q 'animation']; then echo "$file has transparency and/or animation." else echo "$file is safe to flaten with Guetzli." fi
Reading through the threads here there are several topics that keep coming up – what happens on uninstall and how to delete generated images. One idea might be to store the webp images in a dedicated directory which matches the path structure of the original. I’ve seen other plugins do the same and always thought it quite neat that it keeps the converted images away from the originals and makes uninstalling/deleting/clean up easier.
]]>Hi,
The plugin seems to be nice and ticking all the boxes – it is working on a few my sites/servers, but unfortunately fails to activate on one specific case, i.e. the plugin produces .htaccess lines recommendation even if the required lines are successfully added to the .htaccess file (and plugin does not activate).
This issue seemed to be raised a few times at the forum, so looking at the code I found that in my case it happens at the Line 71 of configs.php with $filesize check – in my ‘failed activation’ case the value is 435…
Is test value of 100 deliberate or arbitrary ? If the latter, maybe consider increasing it to avoid ‘mysterious’ cases when the plugin cannot activate ?
if( $code == 200 ){
if( $filesize > 100 ){
deactivate_plugins( __DIR__ );
]]>
I havea problems with activating the plugin on the local env with Docker php8 + appache 2.4 wp 6.2.2.
i’ve get this, when i try to activate plugin:
error:Failed to connect to localhost port 8083: Connection refused
This message was triggered by images-to-webp.
Call stack:
wp_die()
wp-content/plugins/images-to-webp/tests/configs.php:63
images_to_webp->activate()
wp-includes/class-wp-hook.php:308
do_action('activate_images-to-webp/images-to-webp.php')
wp-admin/includes/plugin.php:691
activate_plugin()
wp-admin/plugins.php:58
I will be glad for any help.
]]>Say I install your plugin, use it to convert a bunch of images, then later decide to uninstall. What will I be left with? Will the existing webp images still work? WP core supports webp now, so would it just keep serving them? Would anything else be left “incomplete” after removing? Thanks, I like the look of this plugin, just checking before using.
]]>Thanks for this plugin.
Although it’s a great idea to deelete webp copies if files are larger compared to jpgs etc. it would be handy to have a simple option to force webp creation for each intermediate size.
In my case I’m using a custom srcset helper function. It checks if the thumbnail size exists as a webp – if so it adds a webp extension.
It would be helpful to rely on the existence of all webp intermediates once a converted equivalent was found.
Is there any hook/option already available?
Best regards,
herrstrietzel
Hi, I would like to know if there is a possibility that after converting the images to WebP the original JPG or PNG images are automatically deleted. I need space on the server and I can’t afford to have both versions of the images.
]]>I am trying to convert existing images I just added this plugin. After I select the folders and click it just gets stuck:
0
Loading all subdirectories…
Stays like this forever and doesn’t move? Any reason or way to resolve this issue?
]]>Cloudflare free plan doesn’t support webp but we want to use free plan. Does your plugin support this case?
]]>Hi,
Is it possible to add support to generate webp images when regenerate with WP Cli?
When I do this: wp media regenerate in cli, webp images are not generated ?? .
Thank you!
]]>Hi. Just a quick query to find out if you are planning to extend support to the bedrock WP template?
Maybe there is something I can do to enable support for this?
I did read other threads and found out that uploads outside wp-content are not supported.
Roots.io Bedrock template file structure is different to enhance the security of a website.
Please see file structure here: https://roots.io/bedrock/
Thanks
]]>Not installed locally, win10 system, server assembly “Apache-Nginx” asks to enter lines in .htaccess after which nothing happens
]]>Not Supported on Nginx Servers.
I’ve followed the guide on how to deploy the code on nginx.conf and site-available/mydomain.conf
But still I can’t activate this Plugin even though I have restarted the nginx server.
]]>Hi, does “Error 404” mean the file can’t be found? Can’t figure out why some images in a folder will convert but others receive this error. Also receiving “Error 0.” I disabled firewall and security plugins, but still no luck. All image extensions checked under General tab.
]]>