a3 Lazy Load - Version 2.4.6

Version Description

This maintenance release has code tweaks to resolve conflicts with third party plugs that use data-src and data-poster attributes, plus compatibility with WordPress 5.7.2

Download this release

Release Info

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

Code changes from version 2.4.5 to 2.4.6

Files changed (3) hide show
  1. a3-lazy-load.php +3 -3
  2. classes/class-a3-lazy-load.php +16 -3
  3. readme.txt +11 -2
a3-lazy-load.php CHANGED
@@ -2,11 +2,11 @@
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.4.5
6
  Author: a3rev Software
7
  Author URI: https://a3rev.com/
8
  Requires at least: 5.0
9
- Tested up to: 5.7
10
  Text Domain: a3-lazy-load
11
  Domain Path: /languages
12
  License: GPLv2 or later
@@ -31,7 +31,7 @@ define('A3_LAZY_LOAD_IMAGES_URL', A3_LAZY_LOAD_URL . '/assets/images');
31
 
32
  define( 'A3_LAZY_LOAD_KEY', 'a3_lazy_load' );
33
  define( 'A3_LAZY_LOAD_PREFIX', 'a3_lazy_load_' );
34
- define( 'A3_LAZY_VERSION', '2.4.5' );
35
  define( 'A3_LAZY_LOAD_G_FONTS', false );
36
 
37
  use \A3Rev\LazyLoad\FrameWork;
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.4.6
6
  Author: a3rev Software
7
  Author URI: https://a3rev.com/
8
  Requires at least: 5.0
9
+ Tested up to: 5.7.2
10
  Text Domain: a3-lazy-load
11
  Domain Path: /languages
12
  License: GPLv2 or later
31
 
32
  define( 'A3_LAZY_LOAD_KEY', 'a3_lazy_load' );
33
  define( 'A3_LAZY_LOAD_PREFIX', 'a3_lazy_load_' );
34
+ define( 'A3_LAZY_VERSION', '2.4.6' );
35
  define( 'A3_LAZY_LOAD_G_FONTS', false );
36
 
37
  use \A3Rev\LazyLoad\FrameWork;
classes/class-a3-lazy-load.php CHANGED
@@ -425,8 +425,14 @@ class LazyLoad
425
  if ( ! ( is_array( $this->_skip_images_classes ) && preg_match( $skip_images_regex, $imgHTML ) ) && ! preg_match( "/src=['\"]data:image/is", $imgHTML ) && ! preg_match( "/src=.*lazy_placeholder.gif['\"]/s", $imgHTML ) && ! $a3_lazy_load_excludes->has_skip_lazy_attribute( $imgHTML ) ) {
426
  $i++;
427
  // replace the src and add the data-src attribute
428
- $replaceHTML = '';
429
- $replaceHTML = preg_replace( '/<img(.*?)src=/is', '<img$1src="' . $this->_placeholder_url . '" data-lazy-type="image" data-src=', $imgHTML );
 
 
 
 
 
 
430
  $replaceHTML = preg_replace( '/<img(.*?)srcset=/is', '<img$1srcset="" data-srcset=', $replaceHTML );
431
 
432
  // add the lazy class to the img element
@@ -619,7 +625,14 @@ class LazyLoad
619
 
620
  $replaceHTML = '';
621
  $replaceHTML = preg_replace( '/video(.*?)src=/is', 'video$1 data-lazy-type="video" data-src=', $imgHTML );
622
- $replaceHTML = preg_replace( '/video(.*?)poster=/is', 'video$1poster="' . $this->_placeholder_url . '" data-lazy-type="video" data-poster=', $replaceHTML );
 
 
 
 
 
 
 
623
 
624
  // add the lazy class to the img element
625
  if ( preg_match( '/class=["\']/i', $replaceHTML ) ) {
425
  if ( ! ( is_array( $this->_skip_images_classes ) && preg_match( $skip_images_regex, $imgHTML ) ) && ! preg_match( "/src=['\"]data:image/is", $imgHTML ) && ! preg_match( "/src=.*lazy_placeholder.gif['\"]/s", $imgHTML ) && ! $a3_lazy_load_excludes->has_skip_lazy_attribute( $imgHTML ) ) {
426
  $i++;
427
  // replace the src and add the data-src attribute
428
+ $replaceHTML = $imgHTML;
429
+
430
+ if ( ! preg_match( "/ data-src=['\"]/is", $replaceHTML ) ) {
431
+ $replaceHTML = preg_replace( '/<img(.*?)src=/is', '<img$1src="' . $this->_placeholder_url . '" data-lazy-type="image" data-src=', $replaceHTML );
432
+ } elseif ( preg_match( "/ src=['\"]/is", $replaceHTML ) ) {
433
+ $replaceHTML = preg_replace( '/ src=(["\'])(.*?)["\']/is', ' src="' . $this->_placeholder_url . '"', $replaceHTML );
434
+ }
435
+
436
  $replaceHTML = preg_replace( '/<img(.*?)srcset=/is', '<img$1srcset="" data-srcset=', $replaceHTML );
437
 
438
  // add the lazy class to the img element
625
 
626
  $replaceHTML = '';
627
  $replaceHTML = preg_replace( '/video(.*?)src=/is', 'video$1 data-lazy-type="video" data-src=', $imgHTML );
628
+
629
+ if ( ! preg_match( "/ data-poster=['\"]/is", $replaceHTML ) ) {
630
+ $replaceHTML = preg_replace( '/video(.*?)poster=/is', 'video$1poster="' . $this->_placeholder_url . '" data-lazy-type="video" data-poster=', $replaceHTML );
631
+ } elseif ( preg_match( "/ poster=['\"]/is", $replaceHTML ) ) {
632
+ $replaceHTML = preg_replace( '/ poster=(["\'])(.*?)["\']/is', ' poster="' . $this->_placeholder_url . '"', $replaceHTML );
633
+ } else {
634
+ $replaceHTML = preg_replace( '/<video/is', '<video poster="' . $this->_placeholder_url . '"', $replaceHTML );
635
+ }
636
 
637
  // add the lazy class to the img element
638
  if ( preg_match( '/class=["\']/i', $replaceHTML ) ) {
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: 5.0
5
- Tested up to: 5.7
6
- Stable tag: 2.4.5
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -199,6 +199,12 @@ Filter tags to add to class name of theme to exclude lazy load on images or vide
199
 
200
  == Changelog ==
201
 
 
 
 
 
 
 
202
  = 2.4.5 - 2021/03/17 =
203
  * This maintenance release updates 23 deprecated jQuery functions for compatibility with the latest version of jQuery in WordPress 5.7
204
  * Tweak - Update JavaScript on plugin framework for compatibility with latest version of jQuery and resolve PHP warning event shorthand is deprecated.
@@ -570,6 +576,9 @@ Filter tags to add to class name of theme to exclude lazy load on images or vide
570
 
571
  == Upgrade Notice ==
572
 
 
 
 
573
  = 2.4.5 =
574
  This maintenance release updates 23 deprecated jQuery functions for compatibility with the latest version of jQuery in WordPress 5.7
575
 
2
  Contributors: a3rev, a3rev Software, nguyencongtuan
3
  Tags: a3 lazy load, Lazy Loading, image lazy load, lazyload
4
  Requires at least: 5.0
5
+ Tested up to: 5.7.2
6
+ Stable tag: 2.4.6
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
199
 
200
  == Changelog ==
201
 
202
+ = 2.4.6 - 2021/06/08 =
203
+ * This maintenance release has code tweaks to resolve conflicts with third party plugs that use data-src and data-poster attributes, plus compatibility with WordPress 5.7.2
204
+ * Tweak - Check if data-src attribute exists on image tags, if so, then lazy load placeholder image for src attribute
205
+ * Tweak - Check if data-poster attribute exists on video tags, if so, then lazy load placeholder image for poster attribute
206
+ * Tweak - Test for compatibility with WordPress 5.7.2
207
+
208
  = 2.4.5 - 2021/03/17 =
209
  * This maintenance release updates 23 deprecated jQuery functions for compatibility with the latest version of jQuery in WordPress 5.7
210
  * Tweak - Update JavaScript on plugin framework for compatibility with latest version of jQuery and resolve PHP warning event shorthand is deprecated.
576
 
577
  == Upgrade Notice ==
578
 
579
+ = 2.4.6 =
580
+ This maintenance release has code tweaks to resolve conflicts with third party plugs that use data-src and data-poster attributes, plus compatibility with WordPress 5.7.2
581
+
582
  = 2.4.5 =
583
  This maintenance release updates 23 deprecated jQuery functions for compatibility with the latest version of jQuery in WordPress 5.7
584