a3 Lazy Load - Version 2.1.0

Version Description

This feature release adds support for WebP images (this support is automatic there are no settings for it), plus compatibility with WordPress 5.3.2

Download this release

Release Info

Developer a3rev
Plugin Icon 128x128 a3 Lazy Load
Version 2.1.0
Comparing to
See all releases

Code changes from version 2.0.0 to 2.1.0

a3-lazy-load.php CHANGED
@@ -2,15 +2,15 @@
2
/*
3
Plugin Name: a3 Lazy Load
4
Description: Speed up your site and enhance frontend user's visual experience in PC's, Tablets and mobile with a3 Lazy Load.
5
- Version: 2.0.0
6
Author: a3rev Software
7
Author URI: https://a3rev.com/
8
Requires at least: 4.0
9
- Tested up to: 5.3.0
10
Text Domain: a3-lazy-load
11
Domain Path: /languages
12
WC requires at least: 2.0.0
13
- WC tested up to: 3.8.0
14
License: GPLv2 or later
15
Copyright © 2011 a3 Revolution Software Development team
16
a3 Revolution Software Development team
@@ -32,7 +32,7 @@ define('A3_LAZY_LOAD_CSS_URL', A3_LAZY_LOAD_URL . '/assets/css');
32
define('A3_LAZY_LOAD_IMAGES_URL', A3_LAZY_LOAD_URL . '/assets/images');
33
34
define( 'A3_LAZY_LOAD_KEY', 'a3_lazy_load' );
35
- define( 'A3_LAZY_VERSION', '2.0.0' );
36
define( 'A3_LAZY_LOAD_G_FONTS', false );
37
38
if ( version_compare( PHP_VERSION, '5.6.0', '>=' ) ) {
2
/*
3
Plugin Name: a3 Lazy Load
4
Description: Speed up your site and enhance frontend user's visual experience in PC's, Tablets and mobile with a3 Lazy Load.
5
+ Version: 2.1.0
6
Author: a3rev Software
7
Author URI: https://a3rev.com/
8
Requires at least: 4.0
9
+ Tested up to: 5.3.2
10
Text Domain: a3-lazy-load
11
Domain Path: /languages
12
WC requires at least: 2.0.0
13
+ WC tested up to: 3.8.1
14
License: GPLv2 or later
15
Copyright © 2011 a3 Revolution Software Development team
16
a3 Revolution Software Development team
32
define('A3_LAZY_LOAD_IMAGES_URL', A3_LAZY_LOAD_URL . '/assets/images');
33
34
define( 'A3_LAZY_LOAD_KEY', 'a3_lazy_load' );
35
+ define( 'A3_LAZY_VERSION', '2.1.0' );
36
define( 'A3_LAZY_LOAD_G_FONTS', false );
37
38
if ( version_compare( PHP_VERSION, '5.6.0', '>=' ) ) {
assets/css/jquery.lazyloadxt.fadein.css CHANGED
@@ -1,5 +1,5 @@
1
.lazy-hidden,.entry img.lazy-hidden, img.thumbnail.lazy-hidden {
2
- opacity: 0;
3
background-color: #ffffff;
4
}
5
figure.wp-block-image img.lazy-hidden {
@@ -13,3 +13,6 @@ figure.wp-block-image img.lazy-hidden {
13
transition: opacity 0.3s;
14
opacity: 1 !important;
15
}
1
.lazy-hidden,.entry img.lazy-hidden, img.thumbnail.lazy-hidden {
2
+ opacity: 0.2;
3
background-color: #ffffff;
4
}
5
figure.wp-block-image img.lazy-hidden {
13
transition: opacity 0.3s;
14
opacity: 1 !important;
15
}
16
+ picture source[type="image/webp"] {
17
+ display: block;
18
+ }
assets/css/jquery.lazyloadxt.spinner.css CHANGED
@@ -6,4 +6,7 @@
6
}
7
figure.wp-block-image img.lazy-hidden {
8
min-width: 150px;
9
}
6
}
7
figure.wp-block-image img.lazy-hidden {
8
min-width: 150px;
9
+ }
10
+ picture source[type="image/webp"] {
11
+ display: block;
12
}
assets/js/jquery.lazyloadxt.srcset.js CHANGED
@@ -33,7 +33,7 @@
33
options[property] = srcsetOptions[property];
34
}
35
}
36
- options.selector += ',img[' + options.srcsetAttr + ']';
37
38
function mathFilter(array, action) {
39
return Math[action].apply(null, $.map(array, function (item) {
@@ -115,4 +115,19 @@
115
}
116
});
117
118
})(window.jQuery || window.Zepto || window.$, window, document);
33
options[property] = srcsetOptions[property];
34
}
35
}
36
+ options.selector += ',img[' + options.srcsetAttr + '],source[' + options.srcsetAttr + ']';
37
38
function mathFilter(array, action) {
39
return Math[action].apply(null, $.map(array, function (item) {
115
}
116
});
117
118
+ $(document).on('lazyshow', 'source', function (e, $el) {
119
+ $(this).removeClass('lazy-hidden');
120
+
121
+ var srcset = $el.attr(options.srcsetAttr);
122
+
123
+ if (srcset) {
124
+ if (!options.srcsetExtended && srcsetSupport) {
125
+ $el.attr('srcset', srcset);
126
+ $el.attr('data-srcset', '');
127
+ } else {
128
+ $el.lazyLoadXT.srcAttr = parseSrcset;
129
+ }
130
+ }
131
+ });
132
+
133
})(window.jQuery || window.Zepto || window.$, window, document);
assets/js/jquery.lazyloadxt.srcset.min.js CHANGED
@@ -1,2 +1,2 @@
1
/* Lazy Load XT 1.1.0 | MIT License */
2
- !function(c,i,o,t){var d,u,l=c.lazyLoadXT,n="srcset"in new Image,x=/^\s*(\S*)/,w=/\S\s+(\d+)w/,f=/\S\s+(\d+)h/,h=/\S\s+([\d\.]+)x/,p=[0,1/0],m=[0,1],e={srcsetAttr:"data-srcset",srcsetExtended:!0,srcsetBaseAttr:"data-srcset-base",srcsetExtAttr:"data-srcset-ext"},g={w:0,h:0,x:0};for(d in e)void 0===l[d]&&(l[d]=e[d]);function A(t,e){return Math[e].apply(null,c.map(t,function(t){return t[d]}))}function v(t){return t[d]>=g[d]||t[d]===u}function E(t){return t[d]===u}function s(t){var e=t.attr(l.srcsetAttr);if(!e)return!1;var r=c.map(e.replace(/(\s[\d.]+[whx]),/g,"$1 @,@ ").split(" @,@ "),function(t){return{url:x.exec(t)[1],w:parseFloat((w.exec(t)||p)[1]),h:parseFloat((f.exec(t)||p)[1]),x:parseFloat((h.exec(t)||m)[1])}});if(!r.length)return!1;var n,s,a=o.documentElement;for(n in g={w:i.innerWidth||a.clientWidth,h:i.innerHeight||a.clientHeight,x:i.devicePixelRatio||1})d=n,u=A(r,"max"),r=c.grep(r,v);for(n in g)d=n,u=A(r,"min"),r=c.grep(r,E);return s=r[0].url,l.srcsetExtended&&(s=(t.attr(l.srcsetBaseAttr)||"")+s+(t.attr(l.srcsetExtAttr)||"")),s}l.selector+=",img["+l.srcsetAttr+"]",c(o).on("lazyshow","img",function(t,e){var r=e.attr(l.srcsetAttr);r&&(!l.srcsetExtended&&n?(e.attr("srcset",r),e.attr("data-srcset","")):e.lazyLoadXT.srcAttr=s)})}(window.jQuery||window.Zepto||window.$,window,document);
1
/* Lazy Load XT 1.1.0 | MIT License */
2
+ !function(t,r,e,s){var n,a,c=t.lazyLoadXT,i="srcset"in new Image,o=/^\s*(\S*)/,d=/\S\s+(\d+)w/,u=/\S\s+(\d+)h/,l=/\S\s+([\d\.]+)x/,x=[0,1/0],w=[0,1],h={srcsetAttr:"data-srcset",srcsetExtended:!0,srcsetBaseAttr:"data-srcset-base",srcsetExtAttr:"data-srcset-ext"},f={w:0,h:0,x:0};for(n in h)void 0===c[n]&&(c[n]=h[n]);function p(r,e){return Math[e].apply(null,t.map(r,function(t){return t[n]}))}function A(t){return t[n]>=f[n]||t[n]===a}function m(t){return t[n]===a}function g(s){var i=s.attr(c.srcsetAttr);if(!i)return!1;var h=t.map(i.replace(/(\s[\d.]+[whx]),/g,"$1 @,@ ").split(" @,@ "),function(t){return{url:o.exec(t)[1],w:parseFloat((d.exec(t)||x)[1]),h:parseFloat((u.exec(t)||x)[1]),x:parseFloat((l.exec(t)||w)[1])}});if(!h.length)return!1;var g,v,y=e.documentElement;for(g in f={w:r.innerWidth||y.clientWidth,h:r.innerHeight||y.clientHeight,x:r.devicePixelRatio||1})n=g,a=p(h,"max"),h=t.grep(h,A);for(g in f)n=g,a=p(h,"min"),h=t.grep(h,m);return v=h[0].url,c.srcsetExtended&&(v=(s.attr(c.srcsetBaseAttr)||"")+v+(s.attr(c.srcsetExtAttr)||"")),v}c.selector+=",img["+c.srcsetAttr+"],source["+c.srcsetAttr+"]",t(e).on("lazyshow","img",function(t,r){var e=r.attr(c.srcsetAttr);e&&(!c.srcsetExtended&&i?(r.attr("srcset",e),r.attr("data-srcset","")):r.lazyLoadXT.srcAttr=g)}),t(e).on("lazyshow","source",function(r,e){t(this).removeClass("lazy-hidden");var s=e.attr(c.srcsetAttr);s&&(!c.srcsetExtended&&i?(e.attr("srcset",s),e.attr("data-srcset","")):e.lazyLoadXT.srcAttr=g)})}(window.jQuery||window.Zepto||window.$,window,document);
classes/class-a3-lazy-load.php CHANGED
@@ -389,6 +389,7 @@ class LazyLoad
389
$include_noscript = $a3_lazy_load_global_settings['a3l_image_include_noscript'];
390
}
391
392
$matches = array();
393
preg_match_all( '/<img[\s\r\n]+.*?>/is', $content, $matches );
394
@@ -432,6 +433,45 @@ class LazyLoad
432
433
$content = str_replace( $search, $replace, $content );
434
435
436
return $content;
437
}
389
$include_noscript = $a3_lazy_load_global_settings['a3l_image_include_noscript'];
390
}
391
392
+ // Normal image
393
$matches = array();
394
preg_match_all( '/<img[\s\r\n]+.*?>/is', $content, $matches );
395
433
434
$content = str_replace( $search, $replace, $content );
435
436
+ // Picture source, support for webp
437
+ $matches = array();
438
+ preg_match_all( '/<source[\s\r\n]+.*?>/is', $content, $matches );
439
+
440
+ $search = array();
441
+ $replace = array();
442
+
443
+ if ( is_array( $this->_skip_images_classes ) ) {
444
+ $skip_images_preg_quoted = array_map( array( $this, 'preg_quote_with_wildcards' ), $this->_skip_images_classes );
445
+ $skip_images_regex = sprintf( '/class=["\'].*(%s).*["\']/s', implode( '|', $skip_images_preg_quoted ) );
446
+ }
447
+
448
+ $i = 0;
449
+ foreach ( $matches[0] as $imgHTML ) {
450
+
451
+ // don't to the replacement if a skip class is provided and the image has the class, or if the image is a data-uri
452
+ if ( ! ( is_array( $this->_skip_images_classes ) && preg_match( $skip_images_regex, $imgHTML ) ) && ! preg_match( "/ data-srcset=['\"]/is", $imgHTML ) ) {
453
+ $i++;
454
+ // replace the srcset and add the data-srcset attribute
455
+ $replaceHTML = '';
456
+ $replaceHTML = preg_replace( '/<source(.*?)srcset=/is', '<source$1srcset="" data-srcset=', $imgHTML );
457
+
458
+ // add the lazy class to the img element
459
+ if ( preg_match( '/class=["\']/i', $replaceHTML ) ) {
460
+ $replaceHTML = preg_replace( '/class=(["\'])(.*?)["\']/is', 'class=$1lazy lazy-hidden $2$1', $replaceHTML );
461
+ } else {
462
+ $replaceHTML = preg_replace( '/<source/is', '<source class="lazy lazy-hidden"', $replaceHTML );
463
+ }
464
+
465
+ array_push( $search, $imgHTML );
466
+ array_push( $replace, $replaceHTML );
467
+ }
468
+ }
469
+
470
+ $search = array_unique( $search );
471
+ $replace = array_unique( $replace );
472
+
473
+ $content = str_replace( $search, $replace, $content );
474
+
475
476
return $content;
477
}
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
Contributors: a3rev, a3rev Software, nguyencongtuan
3
Tags: a3 lazy load, Lazy Loading , image lazy load, lazyload
4
Requires at least: 4.5
5
- Tested up to: 5.3.0
6
- Stable tag: 2.0.0
7
License: GPLv3
8
License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
@@ -63,6 +63,19 @@ a3 Lazy Load has built in support for content that is added by iframe from any s
63
* There are no setting options for exclude /amp - Lazy Load is just never applied to the /amp endpoint
64
* When the url is loaded in browser without /amp Lazy Load is applied
65
66
= ADVANCED CUSTOM FIELDS =
67
68
Fully compatible with the very popular Advanced Custom Fields plugin, Free and Premium versions.
@@ -75,9 +88,6 @@ a3 Lazy Load gives you the option to lazy load images with a FADE IN or SPINNER
75
* SPINNER [see demo](http://ressio.github.io/lazy-load-xt/demo/spinner.htm)
76
* Option to create a custom Lazy Load pre-load background colour
77
78
- = WOOCOMMERCE =
79
-
80
- a3 lazy Load is built and tested to be fully compatible with the very widely used WooCommerce plugin
81
82
= PERFORMANCE TWEAKS =
83
@@ -112,8 +122,9 @@ These are just some of the more popular plugins that are either tested 100% comp
112
* Plugin - WordPress AMP
113
* Plugin - WPTouch. Note - Set to not apply on Mobiles if WPTouch is installed
114
* Plugin - MobilePress - Set to not apply on Mobiles if MobilePress is installed
115
* Plugins - Will not conflict with any plugin that has lazy load built in
116
- * CDN's - Cloudfront, Cloudflare and all other known CDN architecture.
117
118
= MORE FEATURES =
119
@@ -132,8 +143,8 @@ Want to add a new language to a3 Lazy Load? Great! You can contribute via [trans
132
133
= Minimum Requirements =
134
135
- * WordPress 4.6 or greater
136
- * PHP version 5.6.0 or greater
137
* MySQL version 5.6 or greater OR MariaDB version 10.0 or greater
138
139
== Frequently Asked Questions ==
@@ -194,6 +205,13 @@ Filter tags to add to class name of theme to exclude lazy load on images or vide
194
195
== Changelog ==
196
197
= 2.0.0 - 2019/11/19 =
198
* This feature release has a lot. PHP is upgraded to Composer PHP Dependency Manager, Compatibility with Jetpack Accelerator, a full security review, and compatibility with with WordPress 5.3.0
199
* Feature - Plugin fully refactored to Composer for cleaner and faster PHP code
@@ -436,6 +454,9 @@ Filter tags to add to class name of theme to exclude lazy load on images or vide
436
437
== Upgrade Notice ==
438
439
= 2.0.0 =
440
This feature release has a lot. PHP is upgraded to Composer PHP Dependency Manager, Compatibility with Jetpack Accelerator, a full security review, and compatibility with with WordPress 5.3.0
441
2
Contributors: a3rev, a3rev Software, nguyencongtuan
3
Tags: a3 lazy load, Lazy Loading , image lazy load, lazyload
4
Requires at least: 4.5
5
+ Tested up to: 5.3.2
6
+ Stable tag: 2.1.0
7
License: GPLv3
8
License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
63
* There are no setting options for exclude /amp - Lazy Load is just never applied to the /amp endpoint
64
* When the url is loaded in browser without /amp Lazy Load is applied
65
66
+ = JETPACK SITE ACCELERATOR (Proton) =
67
+
68
+ This is an option that you turn on as the Jetpack Accelerator (Proton CDN images) has its own lazy load feature that needs to be OFF first to be able use a3 Lazy Load as your lazy Load engine. Some users prefer to use a3 Lazy Load as it applies Lazy Load to the whole site not just images.
69
+
70
+ = WebP IMAGES =
71
+
72
+ As of a3 Lazy Load has built in automatic support for WebP images. There are no settings for this as a3 Lazy Load will automatically detect if an image has a WebP version and load that. If no WebP image exists the appropriate jpg or png version will be loaded. Also fully support browser detection of WebP.
73
+
74
+
75
+ = WOOCOMMERCE =
76
+
77
+ a3 lazy Load is built and tested to be fully compatible with the very widely used WooCommerce plugin
78
+
79
= ADVANCED CUSTOM FIELDS =
80
81
Fully compatible with the very popular Advanced Custom Fields plugin, Free and Premium versions.
88
* SPINNER [see demo](http://ressio.github.io/lazy-load-xt/demo/spinner.htm)
89
* Option to create a custom Lazy Load pre-load background colour
90
91
92
= PERFORMANCE TWEAKS =
93
122
* Plugin - WordPress AMP
123
* Plugin - WPTouch. Note - Set to not apply on Mobiles if WPTouch is installed
124
* Plugin - MobilePress - Set to not apply on Mobiles if MobilePress is installed
125
+ * WebP Plugins - Smush, EWWW Image Optimizer, Imagify, WebP Express
126
* Plugins - Will not conflict with any plugin that has lazy load built in
127
+ * CDN's - JetPack Accelerator, Cloudfront, Cloudflare and all other known CDN architecture.
128
129
= MORE FEATURES =
130
143
144
= Minimum Requirements =
145
146
+ * WordPress 4.9 or greater
147
+ * PHP version 7.0.0 or greater
148
* MySQL version 5.6 or greater OR MariaDB version 10.0 or greater
149
150
== Frequently Asked Questions ==
205
206
== Changelog ==
207
208
+ = 2.1.0 - 2020/01/02 =
209
+ * This feature release adds support for WebP images (this support is automatic there are no settings for it), plus compatibility with WordPress 5.3.2
210
+ * Feature - Add auto support WebP images
211
+ * Tweak - Update lazyloadxt.srcset for WebP image support
212
+ * Tweak - Update lazy style for WebP image support
213
+ * Tweak - Test for compatibility with WordPress 5.3.2
214
+
215
= 2.0.0 - 2019/11/19 =
216
* This feature release has a lot. PHP is upgraded to Composer PHP Dependency Manager, Compatibility with Jetpack Accelerator, a full security review, and compatibility with with WordPress 5.3.0
217
* Feature - Plugin fully refactored to Composer for cleaner and faster PHP code
454
455
== Upgrade Notice ==
456
457
+ = 2.1.0 =
458
+ This feature release adds support for WebP images (this support is automatic there are no settings for it), plus compatibility with WordPress 5.3.2
459
+
460
= 2.0.0 =
461
This feature release has a lot. PHP is upgraded to Composer PHP Dependency Manager, Compatibility with Jetpack Accelerator, a full security review, and compatibility with with WordPress 5.3.0
462