Skip to content

Commit b5749a0

Browse files
committed
Release new version 2.4.6
= 2.4.6 - 2021/06/08 = * 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 * Tweak - Check if data-src attribute exists on image tags, if so, then lazy load placeholder image for src attribute * Tweak - Check if data-poster attribute exists on video tags, if so, then lazy load placeholder image for poster attribute * Tweak - Test for compatibility with WordPress 5.7.2
1 parent 9116c25 commit b5749a0

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

a3-lazy-load.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
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.4.5
5+
Version: 2.4.6
66
Author: a3rev Software
77
Author URI: https://a3rev.com/
88
Requires at least: 5.0
9-
Tested up to: 5.7
9+
Tested up to: 5.7.2
1010
Text Domain: a3-lazy-load
1111
Domain Path: /languages
1212
License: GPLv2 or later
@@ -31,7 +31,7 @@
3131

3232
define( 'A3_LAZY_LOAD_KEY', 'a3_lazy_load' );
3333
define( 'A3_LAZY_LOAD_PREFIX', 'a3_lazy_load_' );
34-
define( 'A3_LAZY_VERSION', '2.4.5' );
34+
define( 'A3_LAZY_VERSION', '2.4.6' );
3535
define( 'A3_LAZY_LOAD_G_FONTS', false );
3636

3737
use \A3Rev\LazyLoad\FrameWork;

classes/class-a3-lazy-load.php

+16-3
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,14 @@ protected function _filter_images( $content, $include_noscript = null ) {
425425
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 ) ) {
426426
$i++;
427427
// 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 );
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+
430436
$replaceHTML = preg_replace( '/<img(.*?)srcset=/is', '<img$1srcset="" data-srcset=', $replaceHTML );
431437

432438
// add the lazy class to the img element
@@ -619,7 +625,14 @@ protected function _filter_videos( $content, $include_noscript = null ) {
619625

620626
$replaceHTML = '';
621627
$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 );
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+
}
623636

624637
// add the lazy class to the img element
625638
if ( preg_match( '/class=["\']/i', $replaceHTML ) ) {

readme.txt

+11-2
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: 5.0
5-
Tested up to: 5.7
6-
Stable tag: 2.4.5
5+
Tested up to: 5.7.2
6+
Stable tag: 2.4.6
77
License: GPLv3
88
License URI: http://www.gnu.org/licenses/gpl-3.0.html
99

@@ -199,6 +199,12 @@ Filter tags to add to class name of theme to exclude lazy load on images or vide
199199

200200
== Changelog ==
201201

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+
202208
= 2.4.5 - 2021/03/17 =
203209
* This maintenance release updates 23 deprecated jQuery functions for compatibility with the latest version of jQuery in WordPress 5.7
204210
* 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
570576

571577
== Upgrade Notice ==
572578

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+
573582
= 2.4.5 =
574583
This maintenance release updates 23 deprecated jQuery functions for compatibility with the latest version of jQuery in WordPress 5.7
575584

0 commit comments

Comments
 (0)