WebP Express - Version 0.11.2

Version Description

  • Fixed bug which caused Alter HTML to fail miserably on some setups
  • AlterHTML now also looks for lazy load attributes in DIV and LI tags.
Download this release

Release Info

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

Code changes from version 0.11.1 to 0.11.2

README.md CHANGED
@@ -155,7 +155,7 @@ First step is to redirect images to the script. Second step is redirecting direc
155
 
156
  The following will redirect all images under wp-content to the script, but only for webp-enabled browsers.
157
 
158
- Insert the following in the `server` context of your configuration file (usually found in `/etc/nginx/sites-available`). The `server` context is the part of the configuration that starts with "server {" and ends with the matching "}".
159
 
160
  ```nginx
161
  location ~* ^/?wp-content/.*\.(png|jpe?g)$ {
@@ -190,8 +190,6 @@ If you still cannot get it to work, you can instead try *method 2*
190
 
191
  Once you got this working, lets improve performance by redirecting directly to existing webp images. This step isn't necessary, as the script also does that - but invoking the php script takes more resources that the direct redirect. Also, a direct redirect will produce *ETag* response header, which is increases caching performance.
192
 
193
- The second step builds on Eugene Lazutkins solution original published [here](http://www.lazutkin.com/blog/2014/02/23/serve-files-with-nginx-conditionally/).
194
-
195
  The rules looks for existing webp files by appending ".webp" to the URL. So for this to work, you must configure *WebP Express* to store the converted files like that:
196
  1. Set *Destination folder* to *mingled*
197
  2. Set *File extension* to *Append ".webp"*
@@ -218,10 +216,12 @@ location ~* ^/?wp-content/.*\.(png|jpe?g)$ {
218
 
219
  Again, beware that if you haven't enabled *png* conversion, you should replace "(png|jpe?g)" with "jpe?g".
220
 
 
 
221
  **Step 3:**: *Caching*
222
  In most cases you can and should allow images to be cached for a long period. To do that, simply uncomment the "expires 365d;" line, by removing the "#" in front of it.
223
 
224
- **Step 4:**: *Routing non-existing webp requests to converter*
225
 
226
  Simply add the following rules below the ones you added in step 2:
227
 
155
 
156
  The following will redirect all images under wp-content to the script, but only for webp-enabled browsers.
157
 
158
+ Insert the following in the `server` context of your configuration file (usually found in `/etc/nginx/sites-available`). "The `server` context" refers to the part of the configuration that starts with "server {" and ends with the matching "}".
159
 
160
  ```nginx
161
  location ~* ^/?wp-content/.*\.(png|jpe?g)$ {
190
 
191
  Once you got this working, lets improve performance by redirecting directly to existing webp images. This step isn't necessary, as the script also does that - but invoking the php script takes more resources that the direct redirect. Also, a direct redirect will produce *ETag* response header, which is increases caching performance.
192
 
 
 
193
  The rules looks for existing webp files by appending ".webp" to the URL. So for this to work, you must configure *WebP Express* to store the converted files like that:
194
  1. Set *Destination folder* to *mingled*
195
  2. Set *File extension* to *Append ".webp"*
216
 
217
  Again, beware that if you haven't enabled *png* conversion, you should replace "(png|jpe?g)" with "jpe?g".
218
 
219
+ Credits: This second step builds on [Eugene Lazutkins solution](http://www.lazutkin.com/blog/2014/02/23/serve-files-with-nginx-conditionally/).
220
+
221
  **Step 3:**: *Caching*
222
  In most cases you can and should allow images to be cached for a long period. To do that, simply uncomment the "expires 365d;" line, by removing the "#" in front of it.
223
 
224
+ **Step 4:**: *Routing requests for non-existing webps to the converter*
225
 
226
  Simply add the following rules below the ones you added in step 2:
227
 
README.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://ko-fi.com/rosell
4
  Tags: webp, images, performance
5
  Requires at least: 4.0
6
  Tested up to: 5.0
7
- Stable tag: 0.11.1
8
  Requires PHP: 5.6
9
  License: GPLv3
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
@@ -573,6 +573,9 @@ Easy enough! - [Go here!](https://ko-fi.com/rosell). Or [here](https://buymeacof
573
  1. WebP Express settings
574
 
575
  == Changelog ==
 
 
 
576
 
577
  = 0.11.1 =
578
  * Fixed bug which caused the new "Convert non-existing webp-files upon request" not to work on all setups
4
  Tags: webp, images, performance
5
  Requires at least: 4.0
6
  Tested up to: 5.0
7
+ Stable tag: 0.11.2
8
  Requires PHP: 5.6
9
  License: GPLv3
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
573
  1. WebP Express settings
574
 
575
  == Changelog ==
576
+ = 0.11.2 =
577
+ * Fixed bug which caused Alter HTML to fail miserably on some setups
578
+ * AlterHTML now also looks for lazy load attributes in DIV and LI tags.
579
 
580
  = 0.11.1 =
581
  * Fixed bug which caused the new "Convert non-existing webp-files upon request" not to work on all setups
changelog.txt CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  = 0.11.1 =
2
  * Fixed bug which caused the new "Convert non-existing webp-files upon request" not to work on all setups
3
 
1
+ = 0.11.2 =
2
+ * Fixed bug which caused Alter HTML to fail miserably on some setups
3
+ * AlterHTML now also looks for lazy load attributes in DIV and LI tags.
4
+
5
  = 0.11.1 =
6
  * Fixed bug which caused the new "Convert non-existing webp-files upon request" not to work on all setups
7
 
composer.json CHANGED
@@ -20,14 +20,11 @@
20
  "rosell-dk/dom-util-for-webp": "^0.2.0"
21
  },
22
  "require-dev": {
23
- "phpunit/phpunit": "^8.0@dev"
24
  },
25
  "scripts": {
26
  "ci": [
27
- "@test",
28
  "@composer validate --no-check-all --strict"
29
- ],
30
- "test": "phpunit tests"
31
  },
32
  "authors": [
33
  {
20
  "rosell-dk/dom-util-for-webp": "^0.2.0"
21
  },
22
  "require-dev": {
 
23
  },
24
  "scripts": {
25
  "ci": [
 
26
  "@composer validate --no-check-all --strict"
27
+ ]
 
28
  },
29
  "authors": [
30
  {
lib/classes/AlterHtmlInit.php CHANGED
@@ -43,12 +43,12 @@ class AlterHtmlInit
43
  }
44
 
45
  if (get_option('webp-express-alter-html-replacement') == 'picture') {
46
- require_once __DIR__ . "../../../vendor/autoload.php";
47
  require_once __DIR__ . '/AlterHtmlHelper.php';
48
  require_once __DIR__ . '/AlterHtmlPicture.php';
49
  return \WebPExpress\AlterHtmlPicture::replace($content);
50
  } else {
51
- require_once __DIR__ . "../../../vendor/autoload.php";
52
  require_once __DIR__ . '/AlterHtmlHelper.php';
53
  require_once __DIR__ . '/AlterHtmlImageUrls.php';
54
  return \WebPExpress\AlterHtmlImageUrls::replace($content);
43
  }
44
 
45
  if (get_option('webp-express-alter-html-replacement') == 'picture') {
46
+ require_once __DIR__ . "/../../vendor/autoload.php";
47
  require_once __DIR__ . '/AlterHtmlHelper.php';
48
  require_once __DIR__ . '/AlterHtmlPicture.php';
49
  return \WebPExpress\AlterHtmlPicture::replace($content);
50
  } else {
51
+ require_once __DIR__ . "/../../vendor/autoload.php";
52
  require_once __DIR__ . '/AlterHtmlHelper.php';
53
  require_once __DIR__ . '/AlterHtmlImageUrls.php';
54
  return \WebPExpress\AlterHtmlImageUrls::replace($content);
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.11.1
7
  * Author: Bjørn Rosell
8
  * Author URI: https://www.bitwise-it.dk
9
  * License: GPL2
@@ -41,5 +41,30 @@ if (get_option('webp-express-alter-html', false)) {
41
  \WebPExpress\AlterHtmlInit::setHooks();
42
  }
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
 
 
45
  //add_action( 'template_redirect', 'webp_express_template_redirect' );
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.11.2
7
  * Author: Bjørn Rosell
8
  * Author URI: https://www.bitwise-it.dk
9
  * License: GPL2
41
  \WebPExpress\AlterHtmlInit::setHooks();
42
  }
43
 
44
+ /*
45
+ function webpexpress_addWebPJs() {
46
+ $url = plugins_url('webpjs/webpjs-0.0.2.min.js', __FILE__);
47
+ $script = <<<EOD
48
+ <script>
49
+ (function(){
50
+ var WebP=new Image();
51
+ WebP.onload=WebP.onerror=function(){
52
+ if(WebP.height!=2){
53
+ var sc=document.createElement('script');
54
+ sc.type='text/javascript';
55
+ sc.async=true;
56
+ var s=document.getElementsByTagName('script')[0];
57
+ sc.src='$url';
58
+ s.parentNode.insertBefore(sc,s);
59
+ }
60
+ };
61
+ WebP.src='data:image/webp;base64,UklGRjoAAABXRUJQVlA4IC4AAACyAgCdASoCAAIALmk0mk0iIiIiIgBoSygABc6WWgAA/veff/0PP8bA//LwYAAA';
62
+ })();
63
+ </script>
64
+ EOD;
65
+ echo $script;
66
+ }
67
 
68
+ add_action( 'wp_head', 'webpexpress_addWebPJs');
69
+ */
70
  //add_action( 'template_redirect', 'webp_express_template_redirect' );