How do I verify that the plugin is working?
Verifying that the plugin works in “Varied image responses” mode 1. Make sure at least one of the conversion methods are working. It should have a green checkmark next to it. 2. If you haven’t saved yet, click “Save settings”. This will put redirection rules into .htaccess files in the relevant directories (typically in uploads, themes and wp-content/webp-express/webp-images, depending on the “Scope” setting) 3. I assume that you checked at least one of the checkboxes in the .htaccess rules section – otherwise you might as well change to “CDN friendly” mode. The first 4. Click the “Live test” buttons to see that the enabled rules actually are working. If they are not, it could be that the server needs a little time to recognize the changed rules.
The live tests are quite thorough and I recommend them over a manual test. However, it doesn’t hurt to do a manual inspection too.
Doing a manual inspection
Note that when WebP Express is serving varied image responses, the image URLs still points to the jpg/png . If the URL is visited using a browser that supports webp, however, the response will be a webp image. So there is a mismatch between the file extension (the filename ends with “jpg” or “png”) and the file type. But luckily, the browser does not rely on the extension to determine the file type, it only looks at the Content-Type response header.
To verify that the plugin is working (without clicking the test button), do the following:
- Open the page in a browser that supports webp, ie Google Chrome
- Right-click the page and choose “Inspect”
- Click the “Network” tab
- Reload the page
- Find a jpeg or png image in the list. In the “type” column, it should say “webp”
You can also look at the headers. When WebP Express has redirected to an existing webp, there will be a “X-WebP-Express” header with the following value: “Redirected directly to existing webp”. If there isn’t (and you have checked “Enable redirection to converter”), you should see a “WebP-Convert-Log” header (WebP-Express uses the WebP Convert for conversions).
No conversions methods are working out of the box
Don’t fret – you have options!
- If you a controlling another WordPress site (where the local conversion methods DO work), you can set up WebP Express there, and then connect to it by configuring the “Remote WebP Express” conversion method.
- You can also setup the ewww conversion method. To use it, you need to purchase an api key. They do not charge credits for webp conversions, so all you ever have to pay is the one dollar start-up fee 🙂 (unless they change their pricing – I have no control over that). You can buy an api key here: https://ewww.io/plans/
- I have written a template letter which you can send to your webhost
- You can try to get one of the local converters working. Check out this page on the webp-convert wiki. There is also this test/troubleshooting script which is handy when messing around with this.
- Finally, if you have access to another server and are comfortable with installing projects with composer, you can install webp-convert-cloud-service . It’s open source.
Of course, there is also the option of using another plugin altogether. I can recommend Optimole. If you want to try that out and want to support me in the process, follow this link . It is an affiliate link and will give me a reward in case you decide to sign up.
It doesn’t work – Although test conversions work, it still serves jpeg images
Actually, you might be mistaking, so first, make sure that you didn’t make the very common mistake of thinking that something with the URL example.com/image.jpg must be a jpeg image. The plugin serves webp images on same URL as the original (unconverted) images, so do not let appearances fool you! Confused? See next FAQ item.
Assuming that you have inspected the content type header, and it doesn’t show “image/webp”, please make sure that: 1) You tested with a browser that supports webp (such as Chrome) 2) The image URL you are looking at are not pointing to another server (such as gravatar.com)
Assuming that all above is in place, please look at the response headers to see if there is a X-WebP-Convert-Status header. If there isn’t, well, then it seems that the problem is that the image request isn’t handed over to WebP Express. Reasons for that can be:
- You are on NGINX (or an Apache/Nginx combination). NGINX requires special attention, please look at that FAQ item
- You are on WAMP. Please look at that FAQ item
I shall write more on this FAQ item… Stay tuned.
How can a webp image be served on an URL ending with “jpg”?
Easy enough. Browsers looks at the content type header rather than the URL to determine what it is that it gets. So, although it can be confusing that the resource at example.com/image.jpg is a webp image, rest assured that the browsers are not confused. To determine if the plugin is working, you must therefore examine the content type response header rather than the URL. See the “How do I verify that the plugin is working?” Faq item.
I am btw considering making an option to have the plugin redirect to the webp instead of serving immediately. That would remove the apparent mismatch between file extension and content type header. However, the cost of doing that will be an extra request for each image, which means extra time and worse performance. I believe you’d be ill advised to use that option, so I guess I will not implement it. But perhaps you have good reasons to use it? If you do, please let me know!
WP CLI, but how do I use it to bulk convert?
Well, first, if you don’t know WP CLI, here is a quick start
WebP Express currently supports commands for converting and flushing webp images throug the CLI. You can use the –help option to learn about the options: wp webp-express –help . Displays the available commands wp webp-express convert –help . Displays the available options for the “convert” command.
A few examples: wp webp-express convert : Creates webp images for all unconverted images wp webp-express convert –reconvert : Also convert images that are already converted wp webp-express convert themes : Only images in the themes folder wp webp-express convert uploads/2021 : Only images in the “2021” folder inside the uploads folder wp webp-express convert –only-png : Only the PNG images wp webp-express convert –quality=50 : Use quality 50 (instead of what was entered in settings screen) wp webp-express convert –quality=50 –near-lossless=50 –alpha-quality=50 –encoding=lossy : More conversion options. encoding can be “lossy”, “lossless” or “auto” wp webp-express convert –converter=cwebp : Specifically use cwebp converter. Other options: “vips”, “imagemagick”, “ffmpeg”. PS: For “ewww” and “wpc” (remote webp express) does not work here.
wp webp-express flushwebp : Remove all webp images wp webp-express flushwebp –only-png : Remove all webp images that are conversions of PNG images
Synopsises:
wp webp-express convert [<location>] [--reconvert] [--only-png] [--only-jpeg] [--quality=<number>] [--near-lossless=<number>] [--alpha-quality=<number>] [--encoding=<auto|lossy|lossless>] [--converter=<converter>] wp webp-express flushwebp [--only-png]
I’m considering adding commands for viewing status, viewing conversion stats, generating the .htaccess files and modifying the settings. Please let me know if you need any of these or perhaps something else.
Blank images in Safari?
WebP Express has three ways of distributing webp to webp-enabled browsers while still sending the originals to webp-disabled browsers. While method 1 can be combined with any of the other methods, you would usually just pick method 1 or one of the others if method 1 cannot be used for you.
Can some of these go wrong? Yes. All!
Method 1: Varied image responses The “Varied image responses” method adds rules to the .htaccess which redirects jpegs and pngs to the corresponding webps (if they exist). The rules have a condition that makes sure they only trigger for browsers supports webp images (this is established by examining the “accept” header).
I the method “varied image responses” because the response on a given image URL varies (the webp is served on the same URL as the jpeg/png).
In the cases where method 1 fails, it is due to systems that cache images by the URL alone. To prevent this from happening, the .htaccess rules adds a Vary:Accept response header. However, most CDNs does not respect that header unless they are configured to do so. Fortunately proxy servers respects it nicely (however often by throwing out the cached image if the accept header doesn’t match)
Method 1 can go wrong if:
- 01You are using a CDN and it hasn’t been set up to handle varied image responses. If this has happened, it is critical that you purge the CDN cache! For information regarding CDN setups, check out the CDN section in this FAQ
- 02Your server doesn’t support adding response headers in .htaccess . On Apache, the “mod_headers” module needs to be enabled. Otherwise the all important Vary:Accept response header will not be set on the response.
- 03Your server doesn’t support SetEnv. However, that module is fortunately very common. I have posted a possible solution to make the rules work without SetEnv here .
- 04You are on Nginx and you haven’t created rules that adds the Vary:Accept header.
I do not believe it can go wrong in other ways. To be certain, please check out this test page . When visiting the test-page with Safari, you should see two images with the “JPG” label over them. When visiting the test-page with a browser that supports webp, you should see two images with the “WEBP” label over them. If you do not see one of these things, please report! (no-one has yet experienced that)
Since WebP Express 0.15.0 you can use the “Live test” button to check that browsers not supporting webp gets the original files and that the Vary:Accept header is returned. Note however that it may not detect CDN caching problems if the CDN doesn’t cache a new image immediately – and across all its nodes.
Met