WebP Express - Version 0.17.5

Version Description

(released: 11 Aug 2020) * Fixed "Path is outside resolved document root" in a certain symlinked configuration. Thanks to @spiderPan on github for providing the fix. * Added content filtering hooks for several third party plugins including ACF and WooCommerce Product Images. With this change, the "Use content filtering hooks" in Alter HTML works in more scenarios, which means there are fewer scenarios where you have to resort to the slower "The complete page" option. Thanks to alextuan for providing the contribution * Fixed problems with Alter HTML when migrating: Absolute paths were cached in the database and the cache was only updated upon saving settings. The paths are not cached anymore (recalculating these on each page load is not a performance problem)

For more info, see the closed issues on the 0.17.5 milestone on the github repository: https://github.com/rosell-dk/webp-express/milestone/30?closed=1

Download this release

Release Info

Developer rosell.dk
Plugin Icon 128x128 WebP Express
Version 0.17.5
Comparing to
See all releases

Code changes from version 0.17.4 to 0.17.5

README.md CHANGED
@@ -654,7 +654,27 @@ Here are my current plans ahead: 0.17 will probably be a file manager-like inter
654
 
655
  If you wish to affect priorities, it is certainly possible. You can try to argue your case in the forum or you can simply let the money do the talking. By donating as little as a cup of coffee on [ko-fi.com/rosell](https://ko-fi.com/rosell), you can leave a wish. I shall take these wishes into account when prioritizing between new features.
656
 
657
- ## 0.17.3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
658
  *(released: 3 Feb 2020)*
659
 
660
  * Fixed critical bug: Fatal error after updating plugin (if one had been postponing updating WebP Express for a while and then updated Wordpress and THEN updated WebP Express)
654
 
655
  If you wish to affect priorities, it is certainly possible. You can try to argue your case in the forum or you can simply let the money do the talking. By donating as little as a cup of coffee on [ko-fi.com/rosell](https://ko-fi.com/rosell), you can leave a wish. I shall take these wishes into account when prioritizing between new features.
656
 
657
+ ## Changes in 0.17.5
658
+ *(released: 11 Aug 2020)*
659
+
660
+ * Fixed "Path is outside resolved document root" in a certain symlinked configuration. Thanks to @robertgres for providing the fix.
661
+ * Added content filtering hooks for several third party plugins including ACF and WooCommerce Product Images. With this change, the "Use content filtering hooks" in Alter HTML works in more scenarios, which means there are fewer scenarios where you have to resort to the slower "The complete page" option. Thanks to alextuan for providing the contribution
662
+ * Fixed problems with Alter HTML when migrating: Absolute paths were cached in the database and the cache was only updated upon saving settings. The paths are not cached anymore (recalculating these on each page load is not a performance problem)
663
+
664
+ For more info, see the closed issues on the 0.17.5 milestone on the github repository: https://github.com/rosell-dk/webp-express/milestone/30?closed=1
665
+
666
+ ## Changes in 0.17.4
667
+ *(released: 26 Jun 2020)*
668
+
669
+ * Fixed bug: Configuration was repeatedly resetting for some users
670
+ * Fixed "Path is outside resolved document root" on file conversion attempts in Windows. Thanks to @Ruzgfpegk from Japan for providing the fix.
671
+ * Fix errors not caught in the selftest. Thanks to Benji Bilheimer from Germany providing the fix.
672
+ * Fix errors not caught in the selftest with unverified certificates. Thanks to Rikesh Ramlochund from Mauritius for providing the fix.
673
+ * Fixed errors with filenames containing encoded symbols. Thanks to Eddie Zhou from Canada for the fix.
674
+
675
+ For more info, see the closed issues on the 0.17.4 milestone on the github repository: https://github.com/rosell-dk/webp-express/milestone/32?closed=1
676
+
677
+ ## Changes in 0.17.3
678
  *(released: 3 Feb 2020)*
679
 
680
  * Fixed critical bug: Fatal error after updating plugin (if one had been postponing updating WebP Express for a while and then updated Wordpress and THEN updated WebP Express)
README.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: rosell.dk
3
  Donate link: https://ko-fi.com/rosell
4
  Tags: webp, images, performance
5
  Requires at least: 4.0
6
- Tested up to: 5.4
7
- Stable tag: 0.17.4
8
  Requires PHP: 5.6
9
  License: GPLv3
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
@@ -13,7 +13,7 @@ Serve autogenerated WebP images instead of jpeg/png to browsers that supports We
13
 
14
  == Description ==
15
 
16
- Almost 4 out of 5 mobile users use a browser that is able to display webp images. Yet, on most websites, they are served jpeg images, which are typically double the size of webp images for a given quality. What a waste of bandwidth! This plugin was created to help remedy that situation. With little effort, Wordpress admins can have their site serving autogenerated webp images to browsers that supports it, while still serving jpeg and png files to browsers that does not support webp.
17
 
18
  ### The image converter
19
  The plugin uses the [WebP Convert](https://github.com/rosell-dk/webp-convert) library to convert images to webp. *WebP Convert* is able to convert images using multiple methods. There are the "local" conversion methods: `imagick`, `cwebp`, `vips`, `gd`. If none of these works on your host, there are the cloud alternatives: `ewww` (paid) or connecting to a Wordpress site where you got WebP Express installed and you enabled the "web service" functionality.
@@ -33,13 +33,14 @@ The plugin implements the "WebP On Demand" solution described [here](https://git
33
  - [WebP Convert Cloud Service](https://github.com/rosell-dk/webp-convert-cloud-service): For the Web Service functionality
34
  - [DOM Util for WebP](https://github.com/rosell-dk/dom-util-for-webp): For the Alter HTML functionality
35
  - [Image MimeType Guesser](https://github.com/rosell-dk/image-mime-type-guesser): For detecting mime types of images.
 
36
 
37
  ### Benefits
38
  - Much faster load time for images in browsers that supports webp. The converted images are typically *less than half the size* (for jpeg), while maintaining the same quality. Bear in mind that for most web sites, images are responsible for the largest part of the waiting time.
39
  - Better user experience (whether performance goes from terrible to bad, or from good to impressive, it is a benefit)
40
  - Better ranking in Google searches (performance is taken into account by Google)
41
  - Less bandwidth consumption - makes a huge difference in the parts of the world where the internet is slow and costly (you know, ~80% of the world population lives under these circumstances).
42
- - Currently ~83% of all traffic, and ~80% of mobile browsing traffic are done with browsers supporting webp. With Mozilla and Microsoft [finally on board](https://medium.com/@richard_90141/webp-image-support-an-8-year-saga-7aa2bedb8d02), these numbers are bound to increase. Check current numbers on [caniuse.com](https://caniuse.com/webp)).
43
  - It's great for the environment too! Reducing network traffic reduces electricity consumption which reduces CO2 emissions.
44
 
45
  == Installation ==
@@ -87,6 +88,28 @@ If you do not have quality detection working, you can try one of the following:
87
  - Use "Remote WebP Express" converter to connect to a site, that *does* have quality detection working
88
  - If you have cwebp converter available, you can configure it to aim for a certain reduction, rather than using the quality parameter. Set this to for example 50%, or even 45%.
89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  ### Notes
91
 
92
  *Note:*
@@ -105,25 +128,54 @@ Bread on the table don't come for free, even though this plugin does, and always
105
  * [Buy me a Coffee](https://ko-fi.com/rosell)
106
  * [Become a backer or sponsor on Patreon](https://www.patreon.com/rosell)
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
  == Frequently Asked Questions ==
110
 
111
  = How do I verify that the plugin is working? =
112
- Once, you have a converter, that works, when you click the "test"-button, you are ready to test the whole stack, and the rewrite rules. To do this, first make sure to select something other than "Do not convert any images!" in *Image types to convert*. Next, click "Save settings". This will save settings, as well as update the *.htaccess*.
113
 
114
- If you are working in a browser that supports webp (ie Google Chrome), you will see a link "Convert test image (show debug)" after a successful save. Click that to test if it works. The screen should show a textual report of the conversion process. If it shows an image, it means that the *.htaccess* redirection isn't working. It may be that your server just needs some time. Some servers has set up caching. It could also be that your images are handled by nginx.
 
 
 
 
 
 
 
 
115
 
116
- Note that the plugin does not change any HTML (unless you enabled the *Alter HTML* option). In the HTML the image src is still set to ie "example.jpg". To verify that the plugin is working (without clicking the test button), do the following:
117
 
118
- - Open the page in Google Chrome
 
 
119
  - Right-click the page and choose "Inspect"
120
  - Click the "Network" tab
121
  - Reload the page
122
  - Find a jpeg or png image in the list. In the "type" column, it should say "webp"
123
 
124
- In order to test that the image is not being reconverted every time, look at the Response headers of the image. There should be a "X-WebP-Convert-Status" header. It should say "Serving freshly converted image" the first time, but "Serving existing converted image" on subsequent requests (WebP-Express is based upon [WebP Convert](https://github.com/rosell-dk/webp-convert)).
125
-
126
- You can also append `?debug` after any image url, in order to run a conversion, and see the conversion report. Also, if you append `?reconvert` after an image url, you will force a reconversion of the image.
127
 
128
  = No conversions methods are working out of the box =
129
  Don't fret - you have options!
@@ -377,6 +429,13 @@ Here are rules if you need to *replace* the file extension with ".webp" rather t
377
  = I am on a Windows server =
378
  Good news! It should work now, thanks to a guy that calls himself lwxbr. At least on XAMPP 7.3.1, Windows 10. https://github.com/rosell-dk/webp-express/pull/213.
379
 
 
 
 
 
 
 
 
380
  = I am using Jetpack =
381
  If you install Jetpack and enable the "Speed up image load times" then Jetpack will alter the HTML such that images are pointed to their CDN.
382
 
@@ -646,10 +705,20 @@ If you got any further questions, look at, or comment on [this topic](https://wo
646
  = Update failed and cannot reinstall =
647
  The 0.17.0 release contained binaries with dots in their filenames, which caused the unpacking during update to fail on a few systems. This failure could leave an incomplete installation. With important files missing - such as the main plugin file - Wordpress no longer registers that the plugin is there (it is missing from the list). However, the folder is there in the file system and trying to install WebP Express again fails because Wordpress complains about just that. The solution is to remove the "webp-express" folder in "plugins" manually (via ftp or a plugin, such as File Manager) and then install WebP Express anew. The setting will be intact. The filenames that caused the trouble where fixed in 0.17.2.
648
 
 
 
 
 
 
 
 
 
 
 
649
  = When is feature X coming? / Roadmap =
650
  No schedule. I move forward as time allows. I currently spend a lot of time answering questions in the support forum. If someone would be nice and help out answering questions here, it would allow me to spend that time developing. Also, donations would allow me to turn down some of the more boring requests from my customers, and speed things up here.
651
 
652
- Here are my current plans ahead: 0.17 will probably be a file manager-like interface for converting / bulk converting / viewing conversion logs / comparing original vs webp visually - kind of a merge of current "test converter" and "bulk conversion" interfaces, and with an addition of a file explorer. 0.18 might allow excluding certain files and folders. 0.19 could be supporting Save-Data header in Varied Image Responses mode (send extra compressed images to clients who wants to use as little bandwidth as possible). 0.19 might be displaying rules for NGINX. 0.20 might be an effort to allow webp for all browsers using [this javascript library](http://libwebpjs.hohenlimburg.org/v0.6.0/). Unfortunately, the javascript librare does not (currently) support srcset attributes, which is why I moved this item down the priority list. We need srcset to be supported for the feature to be useful. 0.21 might be WAMP support. The current milestones, their subtasks and their progress can be viewed here: https://github.com/rosell-dk/webp-express/milestones
653
 
654
  If you wish to affect priorities, it is certainly possible. You can try to argue your case in the forum or you can simply let the money do the talking. By donating as little as a cup of coffee on [ko-fi.com/rosell](https://ko-fi.com/rosell), you can leave a wish. I shall take these wishes into account when prioritizing between new features.
655
 
@@ -662,6 +731,14 @@ Easy enough! - [Go here!](https://ko-fi.com/rosell). Or [here](https://buymeacof
662
 
663
  == Changelog ==
664
 
 
 
 
 
 
 
 
 
665
  = 0.17.4 =
666
  *(released: 26 Jun 2020)*
667
  * Fixed bug: Configuration was repeatedly resetting for some users
@@ -1084,6 +1161,9 @@ For older releases, check out changelog.txt
1084
 
1085
  == Upgrade Notice ==
1086
 
 
 
 
1087
  = 0.17.4 =
1088
  * Various fixes by community. Maintainer is partly back. Will be fully back mid august.
1089
 
3
  Donate link: https://ko-fi.com/rosell
4
  Tags: webp, images, performance
5
  Requires at least: 4.0
6
+ Tested up to: 5.5
7
+ Stable tag: 0.17.5
8
  Requires PHP: 5.6
9
  License: GPLv3
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
13
 
14
  == Description ==
15
 
16
+ About 4 out of 5 F users use a browser that is able to display webp images. Yet, on most websites, they are served jpeg images, which are typically double the size of webp images for a given quality. What a waste of bandwidth! This plugin was created to help remedy that situation. With little effort, Wordpress admins can have their site serving autogenerated webp images to browsers that supports it, while still serving jpeg and png files to browsers that does not support webp.
17
 
18
  ### The image converter
19
  The plugin uses the [WebP Convert](https://github.com/rosell-dk/webp-convert) library to convert images to webp. *WebP Convert* is able to convert images using multiple methods. There are the "local" conversion methods: `imagick`, `cwebp`, `vips`, `gd`. If none of these works on your host, there are the cloud alternatives: `ewww` (paid) or connecting to a Wordpress site where you got WebP Express installed and you enabled the "web service" functionality.
33
  - [WebP Convert Cloud Service](https://github.com/rosell-dk/webp-convert-cloud-service): For the Web Service functionality
34
  - [DOM Util for WebP](https://github.com/rosell-dk/dom-util-for-webp): For the Alter HTML functionality
35
  - [Image MimeType Guesser](https://github.com/rosell-dk/image-mime-type-guesser): For detecting mime types of images.
36
+ - [HTAccess Capability Tester](https://github.com/rosell-dk/htaccess-capability-tester): For testing .htaccess capabilities in a given directory, using live tests
37
 
38
  ### Benefits
39
  - Much faster load time for images in browsers that supports webp. The converted images are typically *less than half the size* (for jpeg), while maintaining the same quality. Bear in mind that for most web sites, images are responsible for the largest part of the waiting time.
40
  - Better user experience (whether performance goes from terrible to bad, or from good to impressive, it is a benefit)
41
  - Better ranking in Google searches (performance is taken into account by Google)
42
  - Less bandwidth consumption - makes a huge difference in the parts of the world where the internet is slow and costly (you know, ~80% of the world population lives under these circumstances).
43
+ - Currently ~86% of all traffic, and ~78% of mobile browsing traffic are done with browsers supporting webp. With Apple finally on board (Safari 14.0), these numbers are bound to increase. Check current numbers on [caniuse.com](https://caniuse.com/webp)).
44
  - It's great for the environment too! Reducing network traffic reduces electricity consumption which reduces CO2 emissions.
45
 
46
  == Installation ==
88
  - Use "Remote WebP Express" converter to connect to a site, that *does* have quality detection working
89
  - If you have cwebp converter available, you can configure it to aim for a certain reduction, rather than using the quality parameter. Set this to for example 50%, or even 45%.
90
 
91
+ ### Verifying that it works (in "Varied image responses" mode)
92
+ 1. Make sure at least one of the conversion methods are working. It should have a green checkmark next to it.
93
+ 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)
94
+ 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
95
+ 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.
96
+
97
+ 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.
98
+
99
+ *Doing a manual inspection*
100
+
101
+ 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.
102
+
103
+ To verify that the plugin is working (without clicking the test button), do the following:
104
+
105
+ - Open the page in a browser that supports webp, ie Google Chrome
106
+ - Right-click the page and choose "Inspect"
107
+ - Click the "Network" tab
108
+ - Reload the page
109
+ - Find a jpeg or png image in the list. In the "type" column, it should say "webp"
110
+
111
+ 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](https://github.com/rosell-dk/webp-convert) for conversions).
112
+
113
  ### Notes
114
 
115
  *Note:*
128
  * [Buy me a Coffee](https://ko-fi.com/rosell)
129
  * [Become a backer or sponsor on Patreon](https://www.patreon.com/rosell)
130
 
131
+ == Supporters of WebP Express ==
132
+
133
+ **Persons currently backing the project via patreon - Thanks!**
134
+
135
+ * Max Kreminsky
136
+ * [Mathieu Gollain-Dupont](https://www.linkedin.com/in/mathieu-gollain-dupont-9938a4a/)
137
+
138
+ **Persons who contributed with coffee within the last 30 days (updated biweekly) - Thanks! **
139
+
140
+ * RobMoore
141
+ * Anon
142
+ * Eder Ribeiro
143
+ * Christian
144
+
145
+ **Persons who contributed with extra generously amounts of coffee / lifetime backing (>30$) - thanks!:**
146
+
147
+ * Justin - BigScoots ($105)
148
+ * Sebastian ($99)
149
+ * Tammy Lee ($90)
150
+ * Max Kreminsky ($65)
151
+ * Steven Sullivan ($51)
152
+
153
 
154
  == Frequently Asked Questions ==
155
 
156
  = How do I verify that the plugin is working? =
 
157
 
158
+ **Verifying that the plugin works in "Varied image responses" mode**
159
+ 1. Make sure at least one of the conversion methods are working. It should have a green checkmark next to it.
160
+ 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)
161
+ 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
162
+ 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.
163
+
164
+ 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.
165
+
166
+ *Doing a manual inspection*
167
 
168
+ 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.
169
 
170
+ To verify that the plugin is working (without clicking the test button), do the following:
171
+
172
+ - Open the page in a browser that supports webp, ie Google Chrome
173
  - Right-click the page and choose "Inspect"
174
  - Click the "Network" tab
175
  - Reload the page
176
  - Find a jpeg or png image in the list. In the "type" column, it should say "webp"
177
 
178
+ 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](https://github.com/rosell-dk/webp-convert) for conversions).
 
 
179
 
180
  = No conversions methods are working out of the box =
181
  Don't fret - you have options!
429
  = I am on a Windows server =
430
  Good news! It should work now, thanks to a guy that calls himself lwxbr. At least on XAMPP 7.3.1, Windows 10. https://github.com/rosell-dk/webp-express/pull/213.
431
 
432
+ = I am on a Litespeed server =
433
+ You do not have to do anything special for it to work on a Litespeed server. You should be able to use WebP Express in any operation mode. For best performance, I however recommend that use the *LiteSpeed Cache* plugin for page caching.
434
+
435
+ LiteSpeed Cache can be set up to maintain separate page caches for browsers that supports webp and browsers that don't. Through this functionality it is possible to use "Alter HTML" with the option "Replace image URLs" and "Only do the replacements in webp enabled browsers" mode.
436
+
437
+ The setup was kindly shared and explained in detail by [@ribeiroeder](https://github.com/ribeiroeder) [here](https://github.com/rosell-dk/webp-express/issues/433)
438
+
439
  = I am using Jetpack =
440
  If you install Jetpack and enable the "Speed up image load times" then Jetpack will alter the HTML such that images are pointed to their CDN.
441
 
705
  = Update failed and cannot reinstall =
706
  The 0.17.0 release contained binaries with dots in their filenames, which caused the unpacking during update to fail on a few systems. This failure could leave an incomplete installation. With important files missing - such as the main plugin file - Wordpress no longer registers that the plugin is there (it is missing from the list). However, the folder is there in the file system and trying to install WebP Express again fails because Wordpress complains about just that. The solution is to remove the "webp-express" folder in "plugins" manually (via ftp or a plugin, such as File Manager) and then install WebP Express anew. The setting will be intact. The filenames that caused the trouble where fixed in 0.17.2.
707
 
708
+ = Alter HTML only replaces some of the images =
709
+
710
+ If you are wondering why Alter HTML are missing some images, it can be due to one of the following reasons:
711
+
712
+ - WebP Express doesn't convert external images, only images on your server. Alter HTML will therefore not alter URLS that unless they point to your server or a CDN that you have added in the *CDN hostnames* section
713
+ - WebP Express has a "Scope" option, which for example can be set to "Uploads and themes". Only images that resides within the selected scope are replaced with webp.
714
+ - If you have selected `<picture>` tags syntax, only images inserted with `<img>`-tags will be replaced (CSS images will not be replaced). Additionally, the `<img>`-tag must have a "src" attribute or a commonly used data attribute for lazyloading (such as “data-src” or “data-lazy-src”)
715
+ - If you have set the "How to replace" option to "Use content filtering hooks", images inserted with some third party plugins/themes might not be replaced. To overcome that, change that setting to "The complete page".
716
+ - The image might have been inserted with javascript. WebP Express doesn't changSome plugins might insert the
717
+
718
  = When is feature X coming? / Roadmap =
719
  No schedule. I move forward as time allows. I currently spend a lot of time answering questions in the support forum. If someone would be nice and help out answering questions here, it would allow me to spend that time developing. Also, donations would allow me to turn down some of the more boring requests from my customers, and speed things up here.
720
 
721
+ Here are my current plans ahead: 0.18 will probably be a file manager-like interface for converting / bulk converting / viewing conversion logs / comparing original vs webp visually - kind of a merge of current "test converter" and "bulk conversion" interfaces, and with an addition of a file explorer. 0.19 might allow excluding certain files and folders. 0.20 could be supporting Save-Data header in Varied Image Responses mode (send extra compressed images to clients who wants to use as little bandwidth as possible). 0.21 might be displaying rules for NGINX. 0.21 might be an effort to allow webp for all browsers using [this javascript library](http://libwebpjs.hohenlimburg.org/v0.6.0/). Unfortunately, the javascript library does not (currently) support srcset attributes, which is why I moved this item down the priority list. We need srcset to be supported for the feature to be useful. 0.21 might be WAMP support. The current milestones, their subtasks and their progress can be viewed here: https://github.com/rosell-dk/webp-express/milestones
722
 
723
  If you wish to affect priorities, it is certainly possible. You can try to argue your case in the forum or you can simply let the money do the talking. By donating as little as a cup of coffee on [ko-fi.com/rosell](https://ko-fi.com/rosell), you can leave a wish. I shall take these wishes into account when prioritizing between new features.
724
 
731
 
732
  == Changelog ==
733
 
734
+ = 0.17.5 =
735
+ *(released: 11 Aug 2020)*
736
+ * Fixed "Path is outside resolved document root" in a certain symlinked configuration. Thanks to @spiderPan on github for providing the fix.
737
+ * Added content filtering hooks for several third party plugins including ACF and WooCommerce Product Images. With this change, the "Use content filtering hooks" in Alter HTML works in more scenarios, which means there are fewer scenarios where you have to resort to the slower "The complete page" option. Thanks to alextuan for providing the contribution
738
+ * Fixed problems with Alter HTML when migrating: Absolute paths were cached in the database and the cache was only updated upon saving settings. The paths are not cached anymore (recalculating these on each page load is not a performance problem)
739
+
740
+ For more info, see the closed issues on the 0.17.5 milestone on the github repository: https://github.com/rosell-dk/webp-express/milestone/30?closed=1
741
+
742
  = 0.17.4 =
743
  *(released: 26 Jun 2020)*
744
  * Fixed bug: Configuration was repeatedly resetting for some users
1161
 
1162
  == Upgrade Notice ==
1163
 
1164
+ = 0.17.5 =
1165
+ * Various fixes, mainly by community.
1166
+
1167
  = 0.17.4 =
1168
  * Various fixes by community. Maintainer is partly back. Will be fully back mid august.
1169
 
changelog.txt CHANGED
@@ -1,3 +1,11 @@
 
 
 
 
 
 
 
 
1
  = 0.17.4 =
2
  *(released: 26 Jun 2020)*
3
  * Hopefully fixed that configuration was resetting for some users
1
+ = 0.17.5 =
2
+ *(released: 11 Aug 2020)*
3
+ * Fixed "Path is outside resolved document root" in a certain symlinked configuration. Thanks to @spiderPan on github for providing the fix.
4
+ * Added content filtering hooks for several third party plugins including ACF and WooCommerce Product Images. With this change, the "Use content filtering hooks" in Alter HTML works in more scenarios, which means there are fewer scenarios where you have to resort to the slower "The complete page" option. Thanks to alextuan for providing the contribution
5
+ * Fixed problems with Alter HTML when migrating: Absolute paths were cached in the database and the cache was only updated upon saving settings. The paths are not cached anymore (recalculating these on each page load is not a performance problem)
6
+
7
+ For more info, see the closed issues on the 0.17.5 milestone on the github repository: https://github.com/rosell-dk/webp-express/milestone/30?closed=1
8
+
9
  = 0.17.4 =
10
  *(released: 26 Jun 2020)*
11
  * Hopefully fixed that configuration was resetting for some users
lib/classes/AlterHtmlHelper.php CHANGED
@@ -3,7 +3,7 @@
3
  namespace WebPExpress;
4
 
5
  //use AlterHtmlInit;
6
-
7
  use \WebPExpress\Paths;
8
  use \WebPExpress\PathHelper;
9
  use \WebPExpress\Multisite;
@@ -39,6 +39,28 @@ class AlterHtmlHelper
39
  }
40
  }
41
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  /**
43
  * Gets relative path between a base url and another.
44
  * Returns false if the url isn't a subpath
@@ -49,7 +71,6 @@ class AlterHtmlHelper
49
  */
50
  public static function getRelUrlPath($imageUrl, $baseUrl)
51
  {
52
-
53
  $baseUrlComponents = parse_url($baseUrl);
54
  /* ie:
55
  (
@@ -146,6 +167,7 @@ class AlterHtmlHelper
146
  {
147
  //error_log('getWebPUrlInImageRoot:' . $sourceUrl . ':' . $baseUrl . ':' . $baseDir);
148
 
 
149
  $srcPathRel = self::getRelUrlPath($sourceUrl, $baseUrl);
150
 
151
  if ($srcPathRel === false) {
@@ -165,7 +187,10 @@ class AlterHtmlHelper
165
 
166
  // We are calculating: $destPathAbs and $destUrl.
167
 
168
- if (!isset(self::$options['bases'][$rootId])) {
 
 
 
169
  return false;
170
  }
171
 
@@ -210,9 +235,7 @@ class AlterHtmlHelper
210
  public static function getWebPUrl($sourceUrl, $returnValueOnFail)
211
  {
212
  // Get the options
213
- if (!isset(self::$options)) {
214
- self::$options = json_decode(Option::getOption('webp-express-alter-html-options', null), true);
215
- }
216
 
217
  // Fail for webp-disabled browsers (when "only-for-webp-enabled-browsers" is set)
218
  if ((self::$options['only-for-webp-enabled-browsers']) && (strpos($_SERVER['HTTP_ACCEPT'], 'image/webp') === false)) {
@@ -248,7 +271,10 @@ class AlterHtmlHelper
248
  //error_log('source url:' . $sourceUrl);
249
 
250
  // Try all image roots
251
- foreach (self::$options['bases'] as $rootId => list($baseDir, $baseUrl)) {
 
 
 
252
  //error_log('baseurl: ' . $baseUrl);
253
  if (Multisite::isMultisite() && ($rootId == 'uploads')) {
254
  $baseUrl = Paths::getUploadUrl();
3
  namespace WebPExpress;
4
 
5
  //use AlterHtmlInit;
6
+ use \WebPExpress\Config;
7
  use \WebPExpress\Paths;
8
  use \WebPExpress\PathHelper;
9
  use \WebPExpress\Multisite;
39
  }
40
  }
41
  */
42
+
43
+ public static function getOptions() {
44
+ if (!isset(self::$options)) {
45
+ self::$options = json_decode(Option::getOption('webp-express-alter-html-options', null), true);
46
+
47
+ // Set scope if it isn't there (it wasn't cached until 0.17.5)
48
+ if (!isset(self::$options['scope'])) {
49
+ $config = Config::loadConfig();
50
+ if ($config) {
51
+ $config = Config::fix($config, false);
52
+ self::$options['scope'] = $config['scope'];
53
+
54
+ Option::updateOption(
55
+ 'webp-express-alter-html-options',
56
+ json_encode(self::$options, JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK),
57
+ true
58
+ );
59
+ }
60
+ }
61
+ }
62
+ }
63
+
64
  /**
65
  * Gets relative path between a base url and another.
66
  * Returns false if the url isn't a subpath
71
  */
72
  public static function getRelUrlPath($imageUrl, $baseUrl)
73
  {
 
74
  $baseUrlComponents = parse_url($baseUrl);
75
  /* ie:
76
  (
167
  {
168
  //error_log('getWebPUrlInImageRoot:' . $sourceUrl . ':' . $baseUrl . ':' . $baseDir);
169
 
170
+
171
  $srcPathRel = self::getRelUrlPath($sourceUrl, $baseUrl);
172
 
173
  if ($srcPathRel === false) {
187
 
188
  // We are calculating: $destPathAbs and $destUrl.
189
 
190
+ // Make sure the options are loaded (and fixed)
191
+ self::getOptions();
192
+
193
+ if (!isset(self::$options['scope']) || !in_array($rootId, self::$options['scope'])) {
194
  return false;
195
  }
196
 
235
  public static function getWebPUrl($sourceUrl, $returnValueOnFail)
236
  {
237
  // Get the options
238
+ self::getOptions();
 
 
239
 
240
  // Fail for webp-disabled browsers (when "only-for-webp-enabled-browsers" is set)
241
  if ((self::$options['only-for-webp-enabled-browsers']) && (strpos($_SERVER['HTTP_ACCEPT'], 'image/webp') === false)) {
271
  //error_log('source url:' . $sourceUrl);
272
 
273
  // Try all image roots
274
+ foreach (self::$options['scope'] as $rootId) {
275
+ $baseDir = Paths::getAbsDirById($rootId);
276
+ $baseUrl = Paths::getUrlById($rootId);
277
+
278
  //error_log('baseurl: ' . $baseUrl);
279
  if (Multisite::isMultisite() && ($rootId == 'uploads')) {
280
  $baseUrl = Paths::getUploadUrl();
lib/classes/AlterHtmlInit.php CHANGED
@@ -82,6 +82,20 @@ class AlterHtmlInit
82
  . '</script>';
83
  }
84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  public static function setHooks() {
86
 
87
  if (Option::getOption('webp-express-alter-html-add-picturefill-js')) {
@@ -106,6 +120,11 @@ class AlterHtmlInit
106
  add_filter( 'the_content', '\\WebPExpress\\AlterHtmlInit::alterHtml', 99999 ); // priority big, so it will be executed last
107
  add_filter( 'the_excerpt', '\\WebPExpress\\AlterHtmlInit::alterHtml', 99999 );
108
  add_filter( 'post_thumbnail_html', '\\WebPExpress\\AlterHtmlInit::alterHtml', 99999);
 
 
 
 
 
109
 
110
 
111
  /*
82
  . '</script>';
83
  }
84
 
85
+ public static function sidebarBeforeAlterHtml()
86
+ {
87
+ ob_start();
88
+ }
89
+
90
+ public static function sidebarAfterAlterHtml()
91
+ {
92
+ $content = ob_get_clean();
93
+
94
+ echo self::alterHtml($content);
95
+
96
+ unset($content);
97
+ }
98
+
99
  public static function setHooks() {
100
 
101
  if (Option::getOption('webp-express-alter-html-add-picturefill-js')) {
120
  add_filter( 'the_content', '\\WebPExpress\\AlterHtmlInit::alterHtml', 99999 ); // priority big, so it will be executed last
121
  add_filter( 'the_excerpt', '\\WebPExpress\\AlterHtmlInit::alterHtml', 99999 );
122
  add_filter( 'post_thumbnail_html', '\\WebPExpress\\AlterHtmlInit::alterHtml', 99999);
123
+ add_filter( 'woocommerce_product_get_image', '\\WebPExpress\\AlterHtmlInit::alterHtml', 99999 );
124
+ add_filter( 'get_avatar', '\\WebPExpress\\AlterHtmlInit::alterHtml', 99999 );
125
+ add_filter( 'acf_the_content', '\\WebPExpress\\AlterHtmlInit::alterHtml', 99999 );
126
+ add_action( 'dynamic_sidebar_before', '\\WebPExpress\\AlterHtmlInit::sidebarBeforeAlterHtml', 0 );
127
+ add_action( 'dynamic_sidebar_after', '\\WebPExpress\\AlterHtmlInit::sidebarAfterAlterHtml', 1000 );
128
 
129
 
130
  /*
lib/classes/Config.php CHANGED
@@ -405,42 +405,7 @@ class Config
405
  $obj['destination-folder'] = $config['destination-folder'];
406
  $obj['destination-extension'] = $config['destination-extension'];
407
  $obj['destination-structure'] = $config['destination-structure'];
408
-
409
- $obj['bases'] = [];
410
- foreach ($config['scope'] as $rootId) {
411
- $obj['bases'][$rootId] = [
412
- Paths::getAbsDirById($rootId),
413
- Paths::getUrlById($rootId)
414
- ];
415
- }
416
-
417
- /*
418
- // TODO!
419
- // Instead of "bases", use image root ids.
420
- // Its a numeric array and there is no id called "content"
421
-
422
- $obj['bases'] = [
423
- 'uploads' => [
424
- Paths::getUploadDirAbs(),
425
- Paths::getUploadUrl()
426
- ],
427
- ];
428
-
429
- if ($obj['destination-structure'] == 'doc-root') {
430
- $obj['bases']['content'] = [
431
- Paths::getContentDirAbs(),
432
- Paths::getContentUrl()
433
- ];
434
- } else {
435
- foreach (Paths::getImageRootIds() as $rootId) {
436
- $obj['bases'][$rootId] = [
437
- Paths::getAbsDirById($rootId),
438
- Paths::getUrlById($rootId)
439
- ];
440
- }
441
- }*/
442
-
443
-
444
  $obj['image-types'] = $config['image-types']; // 0=none,1=jpg, 2=png, 3=both
445
 
446
  Option::updateOption(
405
  $obj['destination-folder'] = $config['destination-folder'];
406
  $obj['destination-extension'] = $config['destination-extension'];
407
  $obj['destination-structure'] = $config['destination-structure'];
408
+ $obj['scope'] = $config['scope'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
409
  $obj['image-types'] = $config['image-types']; // 0=none,1=jpg, 2=png, 3=both
410
 
411
  Option::updateOption(
lib/classes/ConvertHelperIndependent.php CHANGED
@@ -571,7 +571,7 @@ APACHE
571
  $text = preg_replace('#' . preg_quote($_SERVER["DOCUMENT_ROOT"]) . '#', '[doc-root]', $text);
572
 
573
  // TODO: Put version number somewhere else. Ie \WebPExpress\VersionNumber::version
574
- $text = 'WebP Express 0.17.4. ' . $msgTop . ', ' . date("Y-m-d H:i:s") . "\n\r\n\r" . $text;
575
 
576
  $logFile = self::getLogFilename($source, $logDir);
577
 
571
  $text = preg_replace('#' . preg_quote($_SERVER["DOCUMENT_ROOT"]) . '#', '[doc-root]', $text);
572
 
573
  // TODO: Put version number somewhere else. Ie \WebPExpress\VersionNumber::version
574
+ $text = 'WebP Express 0.17.5. ' . $msgTop . ', ' . date("Y-m-d H:i:s") . "\n\r\n\r" . $text;
575
 
576
  $logFile = self::getLogFilename($source, $logDir);
577
 
lib/classes/SanityCheck.php CHANGED
@@ -299,12 +299,6 @@ class SanityCheck
299
  return $input;
300
  }
301
 
302
- // See if $filePath begins with $dirPath + '/'. If it does, we are done and OK!
303
- if (strpos($input, $docRoot . '/') === 0) {
304
- return $input;
305
- }
306
-
307
-
308
  // Use realpath to expand symbolic links and check if it exists
309
  $docRootSymLinksExpanded = @realpath($docRoot);
310
  if ($docRootSymLinksExpanded === false) {
@@ -315,6 +309,13 @@ class SanityCheck
315
  // Cannot resolve document root, so cannot test if in document root
316
  return $input;
317
  }
 
 
 
 
 
 
 
318
  $docRootSymLinksExpanded = rtrim($docRootSymLinksExpanded, '\\/');
319
  $docRootSymLinksExpanded = self::absPathExists($docRootSymLinksExpanded, 'Document root does not exist!');
320
  $docRootSymLinksExpanded = self::absPathExistsAndIsDir($docRootSymLinksExpanded, 'Document root is not a directory!');
299
  return $input;
300
  }
301
 
 
 
 
 
 
 
302
  // Use realpath to expand symbolic links and check if it exists
303
  $docRootSymLinksExpanded = @realpath($docRoot);
304
  if ($docRootSymLinksExpanded === false) {
309
  // Cannot resolve document root, so cannot test if in document root
310
  return $input;
311
  }
312
+
313
+ // See if $filePath begins with the realpath of the $docRoot + '/'. If it does, we are done and OK!
314
+ // (pull #429)
315
+ if (strpos($input, $docRootSymLinksExpanded . '/') === 0) {
316
+ return $input;
317
+ }
318
+
319
  $docRootSymLinksExpanded = rtrim($docRootSymLinksExpanded, '\\/');
320
  $docRootSymLinksExpanded = self::absPathExists($docRootSymLinksExpanded, 'Document root does not exist!');
321
  $docRootSymLinksExpanded = self::absPathExistsAndIsDir($docRootSymLinksExpanded, 'Document root is not a directory!');
lib/classes/SelfTestHelper.php CHANGED
@@ -506,7 +506,7 @@ class SelfTestHelper
506
  return $log;
507
  }
508
 
509
- public static function diagnoseFailedRewrite($config)
510
  {
511
  if (($config['destination-structure'] == 'image-roots') && (!PathHelper::isDocRootAvailableAndResolvable())) {
512
  $log[] = 'The problem is probably this combination:';
@@ -526,7 +526,10 @@ class SelfTestHelper
526
  }
527
 
528
  //$log[] = '## Diagnosing';
529
- if (PlatformInfo::isNginx()) {
 
 
 
530
  // Nginx
531
  $log[] = 'Notice that you are on Nginx and the rules that WebP Express stores in the *.htaccess* files probably does not ' .
532
  'have any effect. ';
506
  return $log;
507
  }
508
 
509
+ public static function diagnoseFailedRewrite($config, $headers)
510
  {
511
  if (($config['destination-structure'] == 'image-roots') && (!PathHelper::isDocRootAvailableAndResolvable())) {
512
  $log[] = 'The problem is probably this combination:';
526
  }
527
 
528
  //$log[] = '## Diagnosing';
529
+
530
+ //if (PlatformInfo::isNginx()) {
531
+ if (strpos($headers['server'], 'nginx') === 0) {
532
+
533
  // Nginx
534
  $log[] = 'Notice that you are on Nginx and the rules that WebP Express stores in the *.htaccess* files probably does not ' .
535
  'have any effect. ';
lib/classes/SelfTestRedirectAbstract.php CHANGED
@@ -24,7 +24,7 @@ abstract class SelfTestRedirectAbstract
24
  private function doRunTestForRoot($rootId)
25
  {
26
  // return [true, ['hello'], false];
27
- // return [false, SelfTestHelper::diagnoseFailedRewrite($this->config), false];
28
 
29
  $result = [];
30
 
24
  private function doRunTestForRoot($rootId)
25
  {
26
  // return [true, ['hello'], false];
27
+ // return [false, SelfTestHelper::diagnoseFailedRewrite($this->config, $headers), false];
28
 
29
  $result = [];
30
 
lib/classes/SelfTestRedirectToConverter.php CHANGED
@@ -78,7 +78,7 @@ class SelfTestRedirectToConverter extends SelfTestRedirectAbstract
78
  'probably that the redirection simply failed';
79
 
80
  $log[] = '### Diagnosing redirection problems';
81
- $log = array_merge($log, SelfTestHelper::diagnoseFailedRewrite($this->config));
82
  }
83
  return [false, $log, $createdTestFiles];
84
  }
78
  'probably that the redirection simply failed';
79
 
80
  $log[] = '### Diagnosing redirection problems';
81
+ $log = array_merge($log, SelfTestHelper::diagnoseFailedRewrite($this->config, $headers));
82
  }
83
  return [false, $log, $createdTestFiles];
84
  }
lib/classes/SelfTestRedirectToExisting.php CHANGED
@@ -72,7 +72,6 @@ class SelfTestRedirectToExisting extends SelfTestRedirectAbstract
72
  $log[] = 'Bummer. There is no "content-type" response header. The test FAILED';
73
  return [false, $log, $createdTestFiles];
74
  }
75
-
76
  if ($headers['content-type'] != 'image/webp') {
77
 
78
  if ($headers['content-type'] == 'image/' . $imageType) {
@@ -108,14 +107,14 @@ class SelfTestRedirectToExisting extends SelfTestRedirectAbstract
108
  'So we can conclude that the rewrite did not happen';
109
  $log[] = 'The test **FAILED**{: .error}.';
110
  $log[] = '#### Diagnosing rewrites';
111
- $log = array_merge($log, SelfTestHelper::diagnoseFailedRewrite($this->config));
112
  }
113
  } else {
114
  $log[] = 'In addition, we did not get a *content-length* header either.' .
115
  $log[] = 'It seems we can conclude that the rewrite did not happen.';
116
  $log[] = 'The test **FAILED**{: .error}.';
117
  $log[] = '#### Diagnosing rewrites';
118
- $log = array_merge($log, SelfTestHelper::diagnoseFailedRewrite($this->config));
119
  }
120
 
121
  return [false, $log, $createdTestFiles];
@@ -129,7 +128,7 @@ class SelfTestRedirectToExisting extends SelfTestRedirectAbstract
129
 
130
  $log[] = 'It seems something went wrong with the redirection.';
131
  $log[] = '#### Diagnosing redirects';
132
- $log = array_merge($log, SelfTestHelper::diagnoseFailedRewrite($this->config));
133
 
134
  return [false, $log, $createdTestFiles];
135
  } else {
72
  $log[] = 'Bummer. There is no "content-type" response header. The test FAILED';
73
  return [false, $log, $createdTestFiles];
74
  }
 
75
  if ($headers['content-type'] != 'image/webp') {
76
 
77
  if ($headers['content-type'] == 'image/' . $imageType) {
107
  'So we can conclude that the rewrite did not happen';
108
  $log[] = 'The test **FAILED**{: .error}.';
109
  $log[] = '#### Diagnosing rewrites';
110
+ $log = array_merge($log, SelfTestHelper::diagnoseFailedRewrite($this->config, $headers));
111
  }
112
  } else {
113
  $log[] = 'In addition, we did not get a *content-length* header either.' .
114
  $log[] = 'It seems we can conclude that the rewrite did not happen.';
115
  $log[] = 'The test **FAILED**{: .error}.';
116
  $log[] = '#### Diagnosing rewrites';
117
+ $log = array_merge($log, SelfTestHelper::diagnoseFailedRewrite($this->config, $headers));
118
  }
119
 
120
  return [false, $log, $createdTestFiles];
128
 
129
  $log[] = 'It seems something went wrong with the redirection.';
130
  $log[] = '#### Diagnosing redirects';
131
+ $log = array_merge($log, SelfTestHelper::diagnoseFailedRewrite($this->config, $headers));
132
 
133
  return [false, $log, $createdTestFiles];
134
  } else {
lib/classes/SelfTestRedirectToWebPRealizer.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
 
3
  namespace WebPExpress;
 
 
4
 
5
  class SelfTestRedirectToWebPRealizer extends SelfTestRedirectAbstract
6
  {
@@ -46,6 +48,19 @@ class SelfTestRedirectToWebPRealizer extends SelfTestRedirectAbstract
46
  Paths::getAbsDirById($rootId)
47
  );
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
  $log[] = '### Lets check that browsers supporting webp gets a freshly converted WEBP ' .
51
  'when a non-existing WEBP is requested, which has a corresponding source';
@@ -59,11 +74,11 @@ class SelfTestRedirectToWebPRealizer extends SelfTestRedirectAbstract
59
  $headers = $results[count($results)-1]['headers'];
60
  $log = array_merge($log, $remoteGetLog);
61
 
 
62
  if (!$success) {
63
  //$log[count($log) - 1] .= '. FAILED';
64
  //$log[] = '*' . $requestUrl . '*';
65
 
66
- $log = array_merge($log, $errors);
67
  $log[] = 'The test **failed**{: .error}';
68
 
69
  $log[] = 'Why did it fail? It could either be that the redirection rule did not trigger ' .
@@ -72,7 +87,7 @@ class SelfTestRedirectToWebPRealizer extends SelfTestRedirectAbstract
72
  'if the latter is the case (sorry!). However, if the redirection rules are the problem, here is some info:';
73
 
74
  $log[] = '### Diagnosing redirection problems (presuming it is the redirection to the script that is failing)';
75
- $log = array_merge($log, SelfTestHelper::diagnoseFailedRewrite($this->config));
76
 
77
 
78
  //$log[count($log) - 1] .= '. FAILED';
@@ -107,7 +122,7 @@ class SelfTestRedirectToWebPRealizer extends SelfTestRedirectAbstract
107
  'probably that the redirection simply failed';
108
 
109
  $log[] = '### Diagnosing redirection problems';
110
- $log = array_merge($log, SelfTestHelper::diagnoseFailedRewrite($this->config));
111
  }
112
  return [false, $log, $createdTestFiles];
113
  }
1
  <?php
2
 
3
  namespace WebPExpress;
4
+ use \WebPExpress\Option;
5
+
6
 
7
  class SelfTestRedirectToWebPRealizer extends SelfTestRedirectAbstract
8
  {
48
  Paths::getAbsDirById($rootId)
49
  );
50
 
51
+ if ($requestUrl === false) {
52
+ $log[] = 'Hm, strange. The source URL does not seem to be in the base root';
53
+ $log[] = 'Source URL:' . $sourceUrl;
54
+ //$log[] = 'Root ID:' . $rootId;
55
+ $log[] = 'Root Url:' . Paths::getUrlById($rootId);
56
+ $log[] = 'Request Url:' . $requestUrl;
57
+ $log[] = 'parsed url:' . print_r(parse_url($sourceUrl), true);
58
+ $log[] = 'parsed url:' . print_r(parse_url(Paths::getUrlById($rootId)), true);
59
+ $log[] = 'scope:' . print_r(AlterHtmlHelper::$options['scope'], true);
60
+ $log[] = 'cached options:' . print_r(AlterHtmlHelper::$options, true);
61
+ $log[] = 'cached options: ' . print_r(Option::getOption('webp-express-alter-html-options', 'not there!'), true);
62
+ }
63
+
64
 
65
  $log[] = '### Lets check that browsers supporting webp gets a freshly converted WEBP ' .
66
  'when a non-existing WEBP is requested, which has a corresponding source';
74
  $headers = $results[count($results)-1]['headers'];
75
  $log = array_merge($log, $remoteGetLog);
76
 
77
+
78
  if (!$success) {
79
  //$log[count($log) - 1] .= '. FAILED';
80
  //$log[] = '*' . $requestUrl . '*';
81
 
 
82
  $log[] = 'The test **failed**{: .error}';
83
 
84
  $log[] = 'Why did it fail? It could either be that the redirection rule did not trigger ' .
87
  'if the latter is the case (sorry!). However, if the redirection rules are the problem, here is some info:';
88
 
89
  $log[] = '### Diagnosing redirection problems (presuming it is the redirection to the script that is failing)';
90
+ $log = array_merge($log, SelfTestHelper::diagnoseFailedRewrite($this->config, $headers));
91
 
92
 
93
  //$log[count($log) - 1] .= '. FAILED';
122
  'probably that the redirection simply failed';
123
 
124
  $log[] = '### Diagnosing redirection problems';
125
+ $log = array_merge($log, SelfTestHelper::diagnoseFailedRewrite($this->config, $headers));
126
  }
127
  return [false, $log, $createdTestFiles];
128
  }
lib/options/options/alter-html/alter-html-options.inc CHANGED
@@ -90,9 +90,6 @@ namespace WebPExpress;
90
  <td>Very comprehensive. Replaces images in inline styles, image urls in lazy load attributes set in &lt;div&gt; or &lt;li&gt; tags, etc.</td>
91
  </tr>
92
  </table>
93
- <p>
94
- Note: The altering only happens for images that are converted and which exists in the same folder as the source with the extension selected in the GENERAL section.
95
- </p>
96
  </div>
97
  <a id="hide_alterhtml_chart_btn" href="javascript:updateAlterHTMLChartVisibility(false);">Hide comparison chart</a>
98
  <div>
@@ -182,8 +179,22 @@ namespace WebPExpress;
182
  }
183
  ?>
184
  <div style="margin-top: 20px">
185
- <label>Where to replace: <?php echo helpIcon(
186
- '<p></p>',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
  'no-margin-left set-margin-right');
188
  ?></label>
189
  <?php
90
  <td>Very comprehensive. Replaces images in inline styles, image urls in lazy load attributes set in &lt;div&gt; or &lt;li&gt; tags, etc.</td>
91
  </tr>
92
  </table>
 
 
 
93
  </div>
94
  <a id="hide_alterhtml_chart_btn" href="javascript:updateAlterHTMLChartVisibility(false);">Hide comparison chart</a>
95
  <div>
179
  }
180
  ?>
181
  <div style="margin-top: 20px">
182
+ <label>How to replace: <?php echo helpIcon(
183
+ '<p>WebP Express can either trigger the HTML altering by hooking into ' .
184
+ 'standard content filtering hooks, or it can do it on the whole page. ' .
185
+ 'Usually, you should select the first option, as it is lighter to ' .
186
+ 'do string manipulation on selected content than on the whole page. ' .
187
+ 'Also, in order to protect from memory problems, the HTML altering is ' .
188
+ 'bypassed when the HTML is larger than 600 kb. ' .
189
+ 'However, not all themes and plugins uses the standard hooks, so in some ' .
190
+ 'cases, you will have to resort to the second option. Since 0.17.5, ' .
191
+ 'hooks has been added for some popular plugins, such as <i>ACF</i> and ' .
192
+ '<i>Woo Commerce Product Image</i>. ' .
193
+ '<p><i>Use content filtering hooks</i> currently supports the following hooks: ' .
194
+ '<i>the_content</i>, <i>the_excerpt</i>, <i>post_thumbnail_html</i>, <i>get_avatar</i>' .
195
+ ', <i>woocommerce_product_get_image</i>, <i>acf_the_content</i>, <i>dynamic_sidebar_before</i>, <i>dynamic_sidebar_after</i>' .
196
+ '. Let me know if you need another content filtering hook to be added.' .
197
+ '</p>',
198
  'no-margin-left set-margin-right');
199
  ?></label>
200
  <?php
webp-express.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WebP Express
4
  * Plugin URI: https://github.com/rosell-dk/webp-express
5
  * Description: Serve autogenerated WebP images instead of jpeg/png to browsers that supports WebP. Works on anything (media library images, galleries, theme images etc).
6
- * Version: 0.17.4
7
  * Author: Bjørn Rosell
8
  * Author URI: https://www.bitwise-it.dk
9
  * License: GPL2
3
  * Plugin Name: WebP Express
4
  * Plugin URI: https://github.com/rosell-dk/webp-express
5
  * Description: Serve autogenerated WebP images instead of jpeg/png to browsers that supports WebP. Works on anything (media library images, galleries, theme images etc).
6
+ * Version: 0.17.5
7
  * Author: Bjørn Rosell
8
  * Author URI: https://www.bitwise-it.dk
9
  * License: GPL2