Skip to content

Commit 73965a1

Browse files
committed
Release new version 2.1.0
= 2.1.0 - 2020/01/02 = * 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 * Feature - Add auto support WebP images * Tweak - Update lazyloadxt.srcset for WebP image support * Tweak - Update lazy style for WebP image support * Tweak - Test for compatibility with WordPress 5.3.2
1 parent ba809c5 commit 73965a1

7 files changed

+97
-15
lines changed

a3-lazy-load.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
/*
33
Plugin Name: a3 Lazy Load
44
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
5+
Version: 2.1.0
66
Author: a3rev Software
77
Author URI: https://a3rev.com/
88
Requires at least: 4.0
9-
Tested up to: 5.3.0
9+
Tested up to: 5.3.2
1010
Text Domain: a3-lazy-load
1111
Domain Path: /languages
1212
WC requires at least: 2.0.0
13-
WC tested up to: 3.8.0
13+
WC tested up to: 3.8.1
1414
License: GPLv2 or later
1515
Copyright © 2011 a3 Revolution Software Development team
1616
a3 Revolution Software Development team
@@ -32,7 +32,7 @@
3232
define('A3_LAZY_LOAD_IMAGES_URL', A3_LAZY_LOAD_URL . '/assets/images');
3333

3434
define( 'A3_LAZY_LOAD_KEY', 'a3_lazy_load' );
35-
define( 'A3_LAZY_VERSION', '2.0.0' );
35+
define( 'A3_LAZY_VERSION', '2.1.0' );
3636
define( 'A3_LAZY_LOAD_G_FONTS', false );
3737

3838
if ( version_compare( PHP_VERSION, '5.6.0', '>=' ) ) {

assets/css/jquery.lazyloadxt.fadein.css

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.lazy-hidden,.entry img.lazy-hidden, img.thumbnail.lazy-hidden {
2-
opacity: 0;
2+
opacity: 0.2;
33
background-color: #ffffff;
44
}
55
figure.wp-block-image img.lazy-hidden {
@@ -13,3 +13,6 @@ figure.wp-block-image img.lazy-hidden {
1313
transition: opacity 0.3s;
1414
opacity: 1 !important;
1515
}
16+
picture source[type="image/webp"] {
17+
display: block;
18+
}

assets/css/jquery.lazyloadxt.spinner.css

+3
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@
66
}
77
figure.wp-block-image img.lazy-hidden {
88
min-width: 150px;
9+
}
10+
picture source[type="image/webp"] {
11+
display: block;
912
}

assets/js/jquery.lazyloadxt.srcset.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
options[property] = srcsetOptions[property];
3434
}
3535
}
36-
options.selector += ',img[' + options.srcsetAttr + ']';
36+
options.selector += ',img[' + options.srcsetAttr + '],source[' + options.srcsetAttr + ']';
3737

3838
function mathFilter(array, action) {
3939
return Math[action].apply(null, $.map(array, function (item) {
@@ -115,4 +115,19 @@
115115
}
116116
});
117117

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+
118133
})(window.jQuery || window.Zepto || window.$, window, document);

assets/js/jquery.lazyloadxt.srcset.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

classes/class-a3-lazy-load.php

+40
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ protected function _filter_images( $content, $include_noscript = null ) {
389389
$include_noscript = $a3_lazy_load_global_settings['a3l_image_include_noscript'];
390390
}
391391

392+
// Normal image
392393
$matches = array();
393394
preg_match_all( '/<img[\s\r\n]+.*?>/is', $content, $matches );
394395

@@ -432,6 +433,45 @@ protected function _filter_images( $content, $include_noscript = null ) {
432433

433434
$content = str_replace( $search, $replace, $content );
434435

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+
435475

436476
return $content;
437477
}

readme.txt

+29-8
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Contributors: a3rev, a3rev Software, nguyencongtuan
33
Tags: a3 lazy load, Lazy Loading , image lazy load, lazyload
44
Requires at least: 4.5
5-
Tested up to: 5.3.0
6-
Stable tag: 2.0.0
5+
Tested up to: 5.3.2
6+
Stable tag: 2.1.0
77
License: GPLv3
88
License URI: http://www.gnu.org/licenses/gpl-3.0.html
99

@@ -63,6 +63,19 @@ a3 Lazy Load has built in support for content that is added by iframe from any s
6363
* There are no setting options for exclude /amp - Lazy Load is just never applied to the /amp endpoint
6464
* When the url is loaded in browser without /amp Lazy Load is applied
6565

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+
6679
= ADVANCED CUSTOM FIELDS =
6780

6881
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
7588
* SPINNER [see demo](http://ressio.github.io/lazy-load-xt/demo/spinner.htm)
7689
* Option to create a custom Lazy Load pre-load background colour
7790

78-
= WOOCOMMERCE =
79-
80-
a3 lazy Load is built and tested to be fully compatible with the very widely used WooCommerce plugin
8191

8292
= PERFORMANCE TWEAKS =
8393

@@ -112,8 +122,9 @@ These are just some of the more popular plugins that are either tested 100% comp
112122
* Plugin - WordPress AMP
113123
* Plugin - WPTouch. Note - Set to not apply on Mobiles if WPTouch is installed
114124
* Plugin - MobilePress - Set to not apply on Mobiles if MobilePress is installed
125+
* WebP Plugins - Smush, EWWW Image Optimizer, Imagify, WebP Express
115126
* Plugins - Will not conflict with any plugin that has lazy load built in
116-
* CDN's - Cloudfront, Cloudflare and all other known CDN architecture.
127+
* CDN's - JetPack Accelerator, Cloudfront, Cloudflare and all other known CDN architecture.
117128

118129
= MORE FEATURES =
119130

@@ -132,8 +143,8 @@ Want to add a new language to a3 Lazy Load? Great! You can contribute via [trans
132143

133144
= Minimum Requirements =
134145

135-
* WordPress 4.6 or greater
136-
* PHP version 5.6.0 or greater
146+
* WordPress 4.9 or greater
147+
* PHP version 7.0.0 or greater
137148
* MySQL version 5.6 or greater OR MariaDB version 10.0 or greater
138149

139150
== Frequently Asked Questions ==
@@ -194,6 +205,13 @@ Filter tags to add to class name of theme to exclude lazy load on images or vide
194205

195206
== Changelog ==
196207

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+
197215
= 2.0.0 - 2019/11/19 =
198216
* 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
199217
* 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
436454

437455
== Upgrade Notice ==
438456

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+
439460
= 2.0.0 =
440461
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
441462

0 commit comments

Comments
 (0)