Lazy Load by WP Rocket - Version 2.2.3

Version Description

  • Enhancement: Improve compatibility for the picture element
  • Enhancement: Apply lazyload on background images set on section, span and li elements
  • Enhancement: also pass $width and $height values to the rocket_lazyload_placeholder filter
  • Bugfix: Use 0 instead of 1 for the default placeholder dimensions to improve compatibility
  • Bugfix: Improve infinite scroll support
  • Bugfix: Exclude Enfold avia-background-fixed background images and data-large_image from lazyload
Download this release

Release Info

Developer wp_media
Plugin Icon 128x128 Lazy Load by WP Rocket
Version 2.2.3
Comparing to
See all releases

Code changes from version 2.2.1 to 2.2.3

composer.lock CHANGED
@@ -273,16 +273,16 @@
273
  },
274
  {
275
  "name": "wp-media/rocket-lazyload-common",
276
- "version": "v2.3.3",
277
  "source": {
278
  "type": "git",
279
  "url": "https://github.com/wp-media/rocket-lazyload-common.git",
280
- "reference": "761a50eab8fe125716c52409c213fcba9af64b59"
281
  },
282
  "dist": {
283
  "type": "zip",
284
- "url": "https://api.github.com/repos/wp-media/rocket-lazyload-common/zipball/761a50eab8fe125716c52409c213fcba9af64b59",
285
- "reference": "761a50eab8fe125716c52409c213fcba9af64b59",
286
  "shasum": ""
287
  },
288
  "require": {
@@ -317,7 +317,7 @@
317
  }
318
  ],
319
  "description": "Common Code between WP Rocket and Lazyload by WP Rocket",
320
- "time": "2019-04-27T22:08:21+00:00"
321
  }
322
  ],
323
  "packages-dev": [
@@ -364,16 +364,16 @@
364
  },
365
  {
366
  "name": "brain/monkey",
367
- "version": "2.2.1",
368
  "source": {
369
  "type": "git",
370
  "url": "https://github.com/Brain-WP/BrainMonkey.git",
371
- "reference": "326a537bf518edd61bc57ab275e8b075ebb8a1a9"
372
  },
373
  "dist": {
374
  "type": "zip",
375
- "url": "https://api.github.com/repos/Brain-WP/BrainMonkey/zipball/326a537bf518edd61bc57ab275e8b075ebb8a1a9",
376
- "reference": "326a537bf518edd61bc57ab275e8b075ebb8a1a9",
377
  "shasum": ""
378
  },
379
  "require": {
@@ -406,9 +406,9 @@
406
  "authors": [
407
  {
408
  "name": "Giuseppe Mazzapica",
 
409
  "email": "giuseppe.mazzapica@gmail.com",
410
- "homepage": "https://gmazzap.me",
411
- "role": "Developer"
412
  }
413
  ],
414
  "description": "Mocking utility for PHP functions and WordPress plugin API",
@@ -424,7 +424,7 @@
424
  "test",
425
  "testing"
426
  ],
427
- "time": "2019-03-15T13:42:24+00:00"
428
  },
429
  {
430
  "name": "dealerdirect/phpcodesniffer-composer-installer",
@@ -711,16 +711,16 @@
711
  },
712
  {
713
  "name": "phpcompatibility/php-compatibility",
714
- "version": "9.1.1",
715
  "source": {
716
  "type": "git",
717
  "url": "https://github.com/PHPCompatibility/PHPCompatibility.git",
718
- "reference": "2b63c5d284ab8857f7b1d5c240ddb507a6b2293c"
719
  },
720
  "dist": {
721
  "type": "zip",
722
- "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/2b63c5d284ab8857f7b1d5c240ddb507a6b2293c",
723
- "reference": "2b63c5d284ab8857f7b1d5c240ddb507a6b2293c",
724
  "shasum": ""
725
  },
726
  "require": {
@@ -734,7 +734,7 @@
734
  "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0"
735
  },
736
  "suggest": {
737
- "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.",
738
  "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
739
  },
740
  "type": "phpcodesniffer-standard",
@@ -749,13 +749,13 @@
749
  },
750
  {
751
  "name": "Wim Godden",
752
- "homepage": "https://github.com/wimg",
753
- "role": "lead"
754
  },
755
  {
756
  "name": "Juliette Reinders Folmer",
757
- "homepage": "https://github.com/jrfnl",
758
- "role": "lead"
759
  }
760
  ],
761
  "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.",
@@ -765,7 +765,7 @@
765
  "phpcs",
766
  "standards"
767
  ],
768
- "time": "2018-12-30T23:16:27+00:00"
769
  },
770
  {
771
  "name": "phpcompatibility/phpcompatibility-paragonie",
@@ -923,16 +923,16 @@
923
  },
924
  {
925
  "name": "phpdocumentor/reflection-docblock",
926
- "version": "4.3.0",
927
  "source": {
928
  "type": "git",
929
  "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
930
- "reference": "94fd0001232e47129dd3504189fa1c7225010d08"
931
  },
932
  "dist": {
933
  "type": "zip",
934
- "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08",
935
- "reference": "94fd0001232e47129dd3504189fa1c7225010d08",
936
  "shasum": ""
937
  },
938
  "require": {
@@ -970,7 +970,7 @@
970
  }
971
  ],
972
  "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
973
- "time": "2017-11-30T07:14:17+00:00"
974
  },
975
  {
976
  "name": "phpdocumentor/type-resolver",
@@ -1021,16 +1021,16 @@
1021
  },
1022
  {
1023
  "name": "phpspec/prophecy",
1024
- "version": "1.8.0",
1025
  "source": {
1026
  "type": "git",
1027
  "url": "https://github.com/phpspec/prophecy.git",
1028
- "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06"
1029
  },
1030
  "dist": {
1031
  "type": "zip",
1032
- "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06",
1033
- "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06",
1034
  "shasum": ""
1035
  },
1036
  "require": {
@@ -1051,8 +1051,8 @@
1051
  }
1052
  },
1053
  "autoload": {
1054
- "psr-0": {
1055
- "Prophecy\\": "src/"
1056
  }
1057
  },
1058
  "notification-url": "https://packagist.org/downloads/",
@@ -1080,7 +1080,7 @@
1080
  "spy",
1081
  "stub"
1082
  ],
1083
- "time": "2018-08-05T17:53:17+00:00"
1084
  },
1085
  {
1086
  "name": "phpunit/php-code-coverage",
@@ -1400,8 +1400,8 @@
1400
  "authors": [
1401
  {
1402
  "name": "Sebastian Bergmann",
1403
- "email": "sebastian@phpunit.de",
1404
- "role": "lead"
1405
  }
1406
  ],
1407
  "description": "The PHP Unit Testing framework.",
@@ -2097,16 +2097,16 @@
2097
  },
2098
  {
2099
  "name": "symfony/yaml",
2100
- "version": "v4.2.7",
2101
  "source": {
2102
  "type": "git",
2103
  "url": "https://github.com/symfony/yaml.git",
2104
- "reference": "6712daf03ee25b53abb14e7e8e0ede1a770efdb1"
2105
  },
2106
  "dist": {
2107
  "type": "zip",
2108
- "url": "https://api.github.com/repos/symfony/yaml/zipball/6712daf03ee25b53abb14e7e8e0ede1a770efdb1",
2109
- "reference": "6712daf03ee25b53abb14e7e8e0ede1a770efdb1",
2110
  "shasum": ""
2111
  },
2112
  "require": {
@@ -2125,7 +2125,7 @@
2125
  "type": "library",
2126
  "extra": {
2127
  "branch-alias": {
2128
- "dev-master": "4.2-dev"
2129
  }
2130
  },
2131
  "autoload": {
@@ -2152,7 +2152,7 @@
2152
  ],
2153
  "description": "Symfony Yaml Component",
2154
  "homepage": "https://symfony.com",
2155
- "time": "2019-03-30T15:58:42+00:00"
2156
  },
2157
  {
2158
  "name": "webmozart/assert",
@@ -2207,16 +2207,16 @@
2207
  },
2208
  {
2209
  "name": "wp-coding-standards/wpcs",
2210
- "version": "2.1.0",
2211
  "source": {
2212
  "type": "git",
2213
- "url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git",
2214
- "reference": "8c7a2e7682de9ef5955251874b639deda51ef470"
2215
  },
2216
  "dist": {
2217
  "type": "zip",
2218
- "url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/8c7a2e7682de9ef5955251874b639deda51ef470",
2219
- "reference": "8c7a2e7682de9ef5955251874b639deda51ef470",
2220
  "shasum": ""
2221
  },
2222
  "require": {
@@ -2248,7 +2248,7 @@
2248
  "standards",
2249
  "wordpress"
2250
  ],
2251
- "time": "2019-04-08T10:53:57+00:00"
2252
  }
2253
  ],
2254
  "aliases": [],
273
  },
274
  {
275
  "name": "wp-media/rocket-lazyload-common",
276
+ "version": "v2.4",
277
  "source": {
278
  "type": "git",
279
  "url": "https://github.com/wp-media/rocket-lazyload-common.git",
280
+ "reference": "fcebb3db1687ce4f88854c6fbc67a36e8ae9e2bf"
281
  },
282
  "dist": {
283
  "type": "zip",
284
+ "url": "https://api.github.com/repos/wp-media/rocket-lazyload-common/zipball/fcebb3db1687ce4f88854c6fbc67a36e8ae9e2bf",
285
+ "reference": "fcebb3db1687ce4f88854c6fbc67a36e8ae9e2bf",
286
  "shasum": ""
287
  },
288
  "require": {
317
  }
318
  ],
319
  "description": "Common Code between WP Rocket and Lazyload by WP Rocket",
320
+ "time": "2019-07-08T16:41:10+00:00"
321
  }
322
  ],
323
  "packages-dev": [
364
  },
365
  {
366
  "name": "brain/monkey",
367
+ "version": "v2.3.0",
368
  "source": {
369
  "type": "git",
370
  "url": "https://github.com/Brain-WP/BrainMonkey.git",
371
+ "reference": "e19ad8f13c31c51507dcad10f186552907384471"
372
  },
373
  "dist": {
374
  "type": "zip",
375
+ "url": "https://api.github.com/repos/Brain-WP/BrainMonkey/zipball/e19ad8f13c31c51507dcad10f186552907384471",
376
+ "reference": "e19ad8f13c31c51507dcad10f186552907384471",
377
  "shasum": ""
378
  },
379
  "require": {
406
  "authors": [
407
  {
408
  "name": "Giuseppe Mazzapica",
409
+ "role": "Developer",
410
  "email": "giuseppe.mazzapica@gmail.com",
411
+ "homepage": "https://gmazzap.me"
 
412
  }
413
  ],
414
  "description": "Mocking utility for PHP functions and WordPress plugin API",
424
  "test",
425
  "testing"
426
  ],
427
+ "time": "2019-07-22T16:10:56+00:00"
428
  },
429
  {
430
  "name": "dealerdirect/phpcodesniffer-composer-installer",
711
  },
712
  {
713
  "name": "phpcompatibility/php-compatibility",
714
+ "version": "9.2.0",
715
  "source": {
716
  "type": "git",
717
  "url": "https://github.com/PHPCompatibility/PHPCompatibility.git",
718
+ "reference": "3db1bf1e28123fd574a4ae2e9a84072826d51b5e"
719
  },
720
  "dist": {
721
  "type": "zip",
722
+ "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/3db1bf1e28123fd574a4ae2e9a84072826d51b5e",
723
+ "reference": "3db1bf1e28123fd574a4ae2e9a84072826d51b5e",
724
  "shasum": ""
725
  },
726
  "require": {
734
  "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0"
735
  },
736
  "suggest": {
737
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.",
738
  "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
739
  },
740
  "type": "phpcodesniffer-standard",
749
  },
750
  {
751
  "name": "Wim Godden",
752
+ "role": "lead",
753
+ "homepage": "https://github.com/wimg"
754
  },
755
  {
756
  "name": "Juliette Reinders Folmer",
757
+ "role": "lead",
758
+ "homepage": "https://github.com/jrfnl"
759
  }
760
  ],
761
  "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.",
765
  "phpcs",
766
  "standards"
767
  ],
768
+ "time": "2019-06-27T19:58:56+00:00"
769
  },
770
  {
771
  "name": "phpcompatibility/phpcompatibility-paragonie",
923
  },
924
  {
925
  "name": "phpdocumentor/reflection-docblock",
926
+ "version": "4.3.1",
927
  "source": {
928
  "type": "git",
929
  "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
930
+ "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c"
931
  },
932
  "dist": {
933
  "type": "zip",
934
+ "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c",
935
+ "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c",
936
  "shasum": ""
937
  },
938
  "require": {
970
  }
971
  ],
972
  "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
973
+ "time": "2019-04-30T17:48:53+00:00"
974
  },
975
  {
976
  "name": "phpdocumentor/type-resolver",
1021
  },
1022
  {
1023
  "name": "phpspec/prophecy",
1024
+ "version": "1.8.1",
1025
  "source": {
1026
  "type": "git",
1027
  "url": "https://github.com/phpspec/prophecy.git",
1028
+ "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76"
1029
  },
1030
  "dist": {
1031
  "type": "zip",
1032
+ "url": "https://api.github.com/repos/phpspec/prophecy/zipball/1927e75f4ed19131ec9bcc3b002e07fb1173ee76",
1033
+ "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76",
1034
  "shasum": ""
1035
  },
1036
  "require": {
1051
  }
1052
  },
1053
  "autoload": {
1054
+ "psr-4": {
1055
+ "Prophecy\\": "src/Prophecy"
1056
  }
1057
  },
1058
  "notification-url": "https://packagist.org/downloads/",
1080
  "spy",
1081
  "stub"
1082
  ],
1083
+ "time": "2019-06-13T12:50:23+00:00"
1084
  },
1085
  {
1086
  "name": "phpunit/php-code-coverage",
1400
  "authors": [
1401
  {
1402
  "name": "Sebastian Bergmann",
1403
+ "role": "lead",
1404
+ "email": "sebastian@phpunit.de"
1405
  }
1406
  ],
1407
  "description": "The PHP Unit Testing framework.",
2097
  },
2098
  {
2099
  "name": "symfony/yaml",
2100
+ "version": "v4.3.2",
2101
  "source": {
2102
  "type": "git",
2103
  "url": "https://github.com/symfony/yaml.git",
2104
+ "reference": "c60ecf5ba842324433b46f58dc7afc4487dbab99"
2105
  },
2106
  "dist": {
2107
  "type": "zip",
2108
+ "url": "https://api.github.com/repos/symfony/yaml/zipball/c60ecf5ba842324433b46f58dc7afc4487dbab99",
2109
+ "reference": "c60ecf5ba842324433b46f58dc7afc4487dbab99",
2110
  "shasum": ""
2111
  },
2112
  "require": {
2125
  "type": "library",
2126
  "extra": {
2127
  "branch-alias": {
2128
+ "dev-master": "4.3-dev"
2129
  }
2130
  },
2131
  "autoload": {
2152
  ],
2153
  "description": "Symfony Yaml Component",
2154
  "homepage": "https://symfony.com",
2155
+ "time": "2019-04-06T14:04:46+00:00"
2156
  },
2157
  {
2158
  "name": "webmozart/assert",
2207
  },
2208
  {
2209
  "name": "wp-coding-standards/wpcs",
2210
+ "version": "2.1.1",
2211
  "source": {
2212
  "type": "git",
2213
+ "url": "https://github.com/WordPress/WordPress-Coding-Standards.git",
2214
+ "reference": "bd9c33152115e6741e3510ff7189605b35167908"
2215
  },
2216
  "dist": {
2217
  "type": "zip",
2218
+ "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/bd9c33152115e6741e3510ff7189605b35167908",
2219
+ "reference": "bd9c33152115e6741e3510ff7189605b35167908",
2220
  "shasum": ""
2221
  },
2222
  "require": {
2248
  "standards",
2249
  "wordpress"
2250
  ],
2251
+ "time": "2019-05-21T02:50:00+00:00"
2252
  }
2253
  ],
2254
  "aliases": [],
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: lazyload, lazy load, images, iframes, thumbnail, thumbnails, smiley, smili
4
  Requires at least: 4.7
5
  Tested up to: 5.2
6
  Requires PHP: 5.6
7
- Stable tag: 2.2.1
8
 
9
  Lazy Load your images and iframes, replace Youtube videos by a preview thumbnail.
10
 
@@ -85,6 +85,18 @@ You can also apply it manually. The element you want to apply lazyload on must h
85
  The element must have the class `rocket-lazyload`, and a `data-bg` attribute, which value is the CSS url for the image.
86
 
87
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
88
  = 2.2.1 =
89
  * Enhancement: add a way to customize the lazyload script options
90
  * Bugfix: Prevent error on Internet Explorer 11
4
  Requires at least: 4.7
5
  Tested up to: 5.2
6
  Requires PHP: 5.6
7
+ Stable tag: 2.2.3
8
 
9
  Lazy Load your images and iframes, replace Youtube videos by a preview thumbnail.
10
 
85
  The element must have the class `rocket-lazyload`, and a `data-bg` attribute, which value is the CSS url for the image.
86
 
87
  == Changelog ==
88
+ = 2.2.3 =
89
+ * Enhancement: Improve compatibility for the picture element
90
+ * Enhancement: Apply lazyload on background images set on section, span and li elements
91
+ * Enhancement: also pass $width and $height values to the rocket_lazyload_placeholder filter
92
+ * Bugfix: Use 0 instead of 1 for the default placeholder dimensions to improve compatibility
93
+ * Bugfix: Improve infinite scroll support
94
+ * Bugfix: Exclude Enfold avia-background-fixed background images and data-large_image from lazyload
95
+
96
+ = 2.2.2 =
97
+ * Bugfix: Auto-exclude data-height-percentage attribute to prevent display issues
98
+ * Bugfix: Correctly handle responsive videos using fitVids again
99
+
100
  = 2.2.1 =
101
  * Enhancement: add a way to customize the lazyload script options
102
  * Bugfix: Prevent error on Internet Explorer 11
rocket-lazy-load.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Lazy Load by WP Rocket
4
  * Plugin URI: http://wordpress.org/plugins/rocket-lazy-load/
5
  * Description: The tiny Lazy Load script for WordPress without jQuery or others libraries.
6
- * Version: 2.2.1
7
  * Author: WP Rocket
8
  * Author URI: https://wp-rocket.me
9
  * Text Domain: rocket-lazy-load
@@ -29,7 +29,7 @@
29
 
30
  defined('ABSPATH') || die('Cheatin\' uh?');
31
 
32
- define('ROCKET_LL_VERSION', '2.2.1');
33
  define('ROCKET_LL_WP_VERSION', '4.7');
34
  define('ROCKET_LL_PHP_VERSION', '5.6');
35
  define('ROCKET_LL_BASENAME', plugin_basename(__FILE__));
3
  * Plugin Name: Lazy Load by WP Rocket
4
  * Plugin URI: http://wordpress.org/plugins/rocket-lazy-load/
5
  * Description: The tiny Lazy Load script for WordPress without jQuery or others libraries.
6
+ * Version: 2.2.3
7
  * Author: WP Rocket
8
  * Author URI: https://wp-rocket.me
9
  * Text Domain: rocket-lazy-load
29
 
30
  defined('ABSPATH') || die('Cheatin\' uh?');
31
 
32
+ define('ROCKET_LL_VERSION', '2.2.3');
33
  define('ROCKET_LL_WP_VERSION', '4.7');
34
  define('ROCKET_LL_PHP_VERSION', '5.6');
35
  define('ROCKET_LL_BASENAME', plugin_basename(__FILE__));
src/Subscriber/LazyloadSubscriber.php CHANGED
@@ -7,8 +7,6 @@
7
 
8
  namespace RocketLazyLoadPlugin\Subscriber;
9
 
10
- defined('ABSPATH') || die('Cheatin\' uh?');
11
-
12
  use RocketLazyLoadPlugin\EventManagement\SubscriberInterface;
13
  use RocketLazyLoadPlugin\Options\OptionArray;
14
  use RocketLazyload\Assets;
@@ -138,20 +136,23 @@ class LazyloadSubscriber implements SubscriberInterface
138
  */
139
  $polyfill = apply_filters('rocket_lazyload_polyfill', false);
140
 
141
- $args = [
142
- 'base_url' => ROCKET_LL_FRONT_JS_URL,
 
 
 
 
 
143
  'threshold' => $threshold,
144
- 'version' => '11.0.6',
145
- 'polyfill' => $polyfill,
146
  ];
147
 
148
  if ($this->option_array->get('images')) {
149
- $args['elements']['image'] = 'img[data-lazy-src]';
150
- $args['elements']['background_image'] = '.rocket-lazyload';
151
  }
152
 
153
  if ($this->option_array->get('iframes')) {
154
- $args['elements']['iframe'] = 'iframe[data-lazy-src]';
155
  }
156
 
157
  /**
@@ -160,11 +161,12 @@ class LazyloadSubscriber implements SubscriberInterface
160
  * @since 2.0
161
  * @author Remy Perona
162
  *
163
- * @param array $args Arguments used for the lazyload script options.
164
  */
165
- $args = apply_filters('rocket_lazyload_script_args', $args);
166
 
167
- $this->assets->insertLazyloadScript($args);
 
168
  }
169
 
170
  /**
@@ -240,7 +242,8 @@ class LazyloadSubscriber implements SubscriberInterface
240
 
241
  $this->assets->insertYoutubeThumbnailCSS(
242
  [
243
- 'base_url' => ROCKET_LL_ASSETS_URL,
 
244
  ]
245
  );
246
  }
@@ -259,17 +262,8 @@ class LazyloadSubscriber implements SubscriberInterface
259
  return false;
260
  }
261
 
262
- // Exclude Page Builders editors.
263
- $excluded_parameters = [
264
- 'fl_builder',
265
- 'et_fb',
266
- 'ct_builder',
267
- ];
268
-
269
- foreach ($excluded_parameters as $excluded) {
270
- if (isset($_GET[ $excluded ])) {
271
- return false;
272
- }
273
  }
274
 
275
  /**
@@ -287,6 +281,32 @@ class LazyloadSubscriber implements SubscriberInterface
287
  return true;
288
  }
289
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  /**
291
  * Gets the content to lazyload
292
  *
7
 
8
  namespace RocketLazyLoadPlugin\Subscriber;
9
 
 
 
10
  use RocketLazyLoadPlugin\EventManagement\SubscriberInterface;
11
  use RocketLazyLoadPlugin\Options\OptionArray;
12
  use RocketLazyload\Assets;
136
  */
137
  $polyfill = apply_filters('rocket_lazyload_polyfill', false);
138
 
139
+ $script_args = [
140
+ 'base_url' => ROCKET_LL_FRONT_JS_URL,
141
+ 'version' => '11.0.6',
142
+ 'polyfill' => $polyfill,
143
+ ];
144
+
145
+ $inline_args = [
146
  'threshold' => $threshold,
 
 
147
  ];
148
 
149
  if ($this->option_array->get('images')) {
150
+ $inline_args['elements']['image'] = 'img[data-lazy-src]';
151
+ $inline_args['elements']['background_image'] = '.rocket-lazyload';
152
  }
153
 
154
  if ($this->option_array->get('iframes')) {
155
+ $inline_args['elements']['iframe'] = 'iframe[data-lazy-src]';
156
  }
157
 
158
  /**
161
  * @since 2.0
162
  * @author Remy Perona
163
  *
164
+ * @param array $inline_args Arguments used for the lazyload script options.
165
  */
166
+ $inline_args = apply_filters('rocket_lazyload_script_args', $inline_args);
167
 
168
+ echo '<script>' . $this->assets->getInlineLazyloadScript($inline_args) . '</script>';
169
+ $this->assets->insertLazyloadScript($script_args);
170
  }
171
 
172
  /**
242
 
243
  $this->assets->insertYoutubeThumbnailCSS(
244
  [
245
+ 'base_url' => ROCKET_LL_ASSETS_URL,
246
+ 'responsive_embeds' => current_theme_supports('responsive-embeds'),
247
  ]
248
  );
249
  }
262
  return false;
263
  }
264
 
265
+ if ($this->isPageBuilder()) {
266
+ return false;
 
 
 
 
 
 
 
 
 
267
  }
268
 
269
  /**
281
  return true;
282
  }
283
 
284
+ /**
285
+ * Checks if current page is a page builder editor.
286
+ *
287
+ * @since 2.2.2
288
+ * @author Remy Perona
289
+ *
290
+ * @return bool
291
+ */
292
+ private function isPageBuilder()
293
+ {
294
+ // Exclude Page Builders editors.
295
+ $excluded_parameters = [
296
+ 'fl_builder',
297
+ 'et_fb',
298
+ 'ct_builder',
299
+ ];
300
+
301
+ foreach ($excluded_parameters as $excluded) {
302
+ if (isset($_GET[ $excluded ])) {
303
+ return true;
304
+ }
305
+ }
306
+
307
+ return false;
308
+ }
309
+
310
  /**
311
  * Gets the content to lazyload
312
  *
vendor/composer/installed.json CHANGED
@@ -274,17 +274,17 @@
274
  },
275
  {
276
  "name": "wp-media/rocket-lazyload-common",
277
- "version": "v2.3.3",
278
- "version_normalized": "2.3.3.0",
279
  "source": {
280
  "type": "git",
281
  "url": "https://github.com/wp-media/rocket-lazyload-common.git",
282
- "reference": "761a50eab8fe125716c52409c213fcba9af64b59"
283
  },
284
  "dist": {
285
  "type": "zip",
286
- "url": "https://api.github.com/repos/wp-media/rocket-lazyload-common/zipball/761a50eab8fe125716c52409c213fcba9af64b59",
287
- "reference": "761a50eab8fe125716c52409c213fcba9af64b59",
288
  "shasum": ""
289
  },
290
  "require": {
@@ -302,7 +302,7 @@
302
  "symfony/yaml": "2.8.*",
303
  "wp-coding-standards/wpcs": "^2.0.0"
304
  },
305
- "time": "2019-04-27T22:08:21+00:00",
306
  "type": "library",
307
  "installation-source": "dist",
308
  "autoload": {
274
  },
275
  {
276
  "name": "wp-media/rocket-lazyload-common",
277
+ "version": "v2.4",
278
+ "version_normalized": "2.4.0.0",
279
  "source": {
280
  "type": "git",
281
  "url": "https://github.com/wp-media/rocket-lazyload-common.git",
282
+ "reference": "fcebb3db1687ce4f88854c6fbc67a36e8ae9e2bf"
283
  },
284
  "dist": {
285
  "type": "zip",
286
+ "url": "https://api.github.com/repos/wp-media/rocket-lazyload-common/zipball/fcebb3db1687ce4f88854c6fbc67a36e8ae9e2bf",
287
+ "reference": "fcebb3db1687ce4f88854c6fbc67a36e8ae9e2bf",
288
  "shasum": ""
289
  },
290
  "require": {
302
  "symfony/yaml": "2.8.*",
303
  "wp-coding-standards/wpcs": "^2.0.0"
304
  },
305
+ "time": "2019-07-08T16:41:10+00:00",
306
  "type": "library",
307
  "installation-source": "dist",
308
  "autoload": {
vendor/wp-media/rocket-lazyload-common/src/Assets.php CHANGED
@@ -15,7 +15,7 @@ class Assets
15
  /**
16
  * Inserts the lazyload script in the HTML
17
  *
18
- * @param array $args Array of arguments to populate the lazyload script options.
19
  * @return void
20
  */
21
  public function insertLazyloadScript($args = [])
@@ -24,22 +24,19 @@ class Assets
24
  }
25
 
26
  /**
27
- * Returns the lazyload inline script
28
  *
29
  * @param array $args Array of arguments to populate the lazyload script options.
30
- * @return string
31
  */
32
- public function getLazyloadScript($args = [])
33
  {
34
  $defaults = [
35
- 'base_url' => '',
36
  'elements' => [
37
  'img',
38
  'iframe',
39
  ],
40
  'threshold' => 300,
41
- 'version' => '',
42
- 'polyfill' => false,
43
  'options' => [],
44
  ];
45
 
@@ -59,26 +56,19 @@ class Assets
59
  ];
60
 
61
  $args = wp_parse_args($args, $defaults);
62
- $min = ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) ? '' : '.min';
63
  $script = '';
64
 
65
  $args['options'] = array_intersect_key($args['options'], $allowed_options);
66
 
67
- if (isset($args['polyfill']) && $args['polyfill']) {
68
- $script .= '<script crossorigin="anonymous" src="https://polyfill.io/v3/polyfill.min.js?flags=gated&features=default%2CIntersectionObserver%2CIntersectionObserverEntry"></script>';
69
- }
70
-
71
- $script .= '<script>
72
- window.lazyLoadOptions = {
73
  elements_selector: "' . esc_attr(implode(',', $args['elements'])) . '",
74
  data_src: "lazy-src",
75
  data_srcset: "lazy-srcset",
76
  data_sizes: "lazy-sizes",
77
- skip_invisible: false,
78
  class_loading: "lazyloading",
79
  class_loaded: "lazyloaded",
80
  threshold: ' . esc_attr($args['threshold']) . ',
81
- callback_load: function(element) {
82
  if ( element.tagName === "IFRAME" && element.dataset.rocketLazyload == "fitvidscompatible" ) {
83
  if (element.classList.contains("lazyloaded") ) {
84
  if (typeof window.jQuery != "undefined") {
@@ -108,6 +98,10 @@ class Assets
108
 
109
  if (window.MutationObserver) {
110
  var observer = new MutationObserver(function(mutations) {
 
 
 
 
111
  mutations.forEach(function(mutation) {
112
  for (i = 0; i < mutation.addedNodes.length; i++) {
113
  if (typeof mutation.addedNodes[i].getElementsByTagName !== \'function\') {
@@ -118,17 +112,29 @@ class Assets
118
  return;
119
  }
120
 
121
- imgs = mutation.addedNodes[i].getElementsByTagName(\'img\');
 
122
  iframes = mutation.addedNodes[i].getElementsByTagName(\'iframe\');
 
123
  rocket_lazy = mutation.addedNodes[i].getElementsByClassName(\'rocket-lazyload\');
124
 
125
- if ( 0 === imgs.length && 0 === iframes.length && 0 === rocket_lazy.length ) {
126
- return;
 
 
 
 
127
  }
128
 
129
- lazyLoadInstance.update();
 
 
130
  }
131
  } );
 
 
 
 
132
  } );
133
 
134
  var b = document.getElementsByTagName("body")[0];
@@ -136,8 +142,32 @@ class Assets
136
 
137
  observer.observe(b, config);
138
  }
139
- }, false);
140
- </script>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
 
142
  /**
143
  * Filters the script tag for the lazyload script
@@ -203,10 +233,10 @@ class Assets
203
 
204
  $args = wp_parse_args($args, $defaults);
205
 
206
- $image = '<img src="https://i.ytimg.com/vi/ID/' . $args['resolution'] . '.jpg" width="' . $allowed_resolutions[ $args['resolution'] ]['width'] . '" height="' . $allowed_resolutions[ $args['resolution'] ]['height'] . '">';
207
 
208
  if (isset($args['lazy_image']) && $args['lazy_image']) {
209
- $image = '<img data-lazy-src="https://i.ytimg.com/vi/ID/' . $args['resolution'] . '.jpg" width="' . $allowed_resolutions[ $args['resolution'] ]['width'] . '" height="' . $allowed_resolutions[ $args['resolution'] ]['height'] . '"><noscript><img src="https://i.ytimg.com/vi/ID/' . $args['resolution'] . '.jpg" width="' . $allowed_resolutions[ $args['resolution'] ]['width'] . '" height="' . $allowed_resolutions[ $args['resolution'] ]['height'] . '"></noscript>';
210
  }
211
 
212
  return "<script>function lazyLoadThumb(e){var t='{$image}',a='<div class=\"play\"></div>';return t.replace(\"ID\",e)+a}function lazyLoadYoutubeIframe(){var e=document.createElement(\"iframe\"),t=\"https://www.youtube.com/embed/ID?autoplay=1\";t+=0===this.dataset.query.length?'':'&'+this.dataset.query;e.setAttribute(\"src\",t.replace(\"ID\",this.dataset.id)),e.setAttribute(\"frameborder\",\"0\"),e.setAttribute(\"allowfullscreen\",\"1\"),this.parentNode.replaceChild(e,this)}document.addEventListener(\"DOMContentLoaded\",function(){var e,t,a=document.getElementsByClassName(\"rll-youtube-player\");for(t=0;t<a.length;t++)e=document.createElement(\"div\"),e.setAttribute(\"data-id\",a[t].dataset.id),e.setAttribute(\"data-query\", a[t].dataset.query),e.innerHTML=lazyLoadThumb(a[t].dataset.id),e.onclick=lazyLoadYoutubeIframe,a[t].appendChild(e)});</script>";
15
  /**
16
  * Inserts the lazyload script in the HTML
17
  *
18
+ * @param array $args Array of arguments to populate the lazyload script tag.
19
  * @return void
20
  */
21
  public function insertLazyloadScript($args = [])
24
  }
25
 
26
  /**
27
+ * Gets the inline lazyload script configuration
28
  *
29
  * @param array $args Array of arguments to populate the lazyload script options.
30
+ * @return void
31
  */
32
+ public function getInlineLazyloadScript($args = [])
33
  {
34
  $defaults = [
 
35
  'elements' => [
36
  'img',
37
  'iframe',
38
  ],
39
  'threshold' => 300,
 
 
40
  'options' => [],
41
  ];
42
 
56
  ];
57
 
58
  $args = wp_parse_args($args, $defaults);
 
59
  $script = '';
60
 
61
  $args['options'] = array_intersect_key($args['options'], $allowed_options);
62
 
63
+ $script .= 'window.lazyLoadOptions = {
 
 
 
 
 
64
  elements_selector: "' . esc_attr(implode(',', $args['elements'])) . '",
65
  data_src: "lazy-src",
66
  data_srcset: "lazy-srcset",
67
  data_sizes: "lazy-sizes",
 
68
  class_loading: "lazyloading",
69
  class_loaded: "lazyloaded",
70
  threshold: ' . esc_attr($args['threshold']) . ',
71
+ callback_loaded: function(element) {
72
  if ( element.tagName === "IFRAME" && element.dataset.rocketLazyload == "fitvidscompatible" ) {
73
  if (element.classList.contains("lazyloaded") ) {
74
  if (typeof window.jQuery != "undefined") {
98
 
99
  if (window.MutationObserver) {
100
  var observer = new MutationObserver(function(mutations) {
101
+ var image_count = 0;
102
+ var iframe_count = 0;
103
+ var rocketlazy_count = 0;
104
+
105
  mutations.forEach(function(mutation) {
106
  for (i = 0; i < mutation.addedNodes.length; i++) {
107
  if (typeof mutation.addedNodes[i].getElementsByTagName !== \'function\') {
112
  return;
113
  }
114
 
115
+ images = mutation.addedNodes[i].getElementsByTagName(\'img\');
116
+ is_image = mutation.addedNodes[i].tagName == "IMG";
117
  iframes = mutation.addedNodes[i].getElementsByTagName(\'iframe\');
118
+ is_iframe = mutation.addedNodes[i].tagName == "IFRAME";
119
  rocket_lazy = mutation.addedNodes[i].getElementsByClassName(\'rocket-lazyload\');
120
 
121
+ image_count += images.length;
122
+ iframe_count += iframes.length;
123
+ rocketlazy_count += rocket_lazy.length;
124
+
125
+ if(is_image){
126
+ image_count += 1;
127
  }
128
 
129
+ if(is_iframe){
130
+ iframe_count += 1;
131
+ }
132
  }
133
  } );
134
+
135
+ if(image_count > 0 || iframe_count > 0 || rocketlazy_count > 0){
136
+ lazyLoadInstance.update();
137
+ }
138
  } );
139
 
140
  var b = document.getElementsByTagName("body")[0];
142
 
143
  observer.observe(b, config);
144
  }
145
+ }, false);';
146
+
147
+ return $script;
148
+ }
149
+
150
+ /**
151
+ * Returns the lazyload inline script
152
+ *
153
+ * @param array $args Array of arguments to populate the lazyload script options.
154
+ * @return string
155
+ */
156
+ public function getLazyloadScript($args = [])
157
+ {
158
+ $defaults = [
159
+ 'base_url' => '',
160
+ 'version' => '',
161
+ 'polyfill' => false,
162
+ ];
163
+
164
+ $args = wp_parse_args($args, $defaults);
165
+ $min = ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) ? '' : '.min';
166
+ $script = '';
167
+
168
+ if (isset($args['polyfill']) && $args['polyfill']) {
169
+ $script .= '<script crossorigin="anonymous" src="https://polyfill.io/v3/polyfill.min.js?flags=gated&features=default%2CIntersectionObserver%2CIntersectionObserverEntry"></script>';
170
+ }
171
 
172
  /**
173
  * Filters the script tag for the lazyload script
233
 
234
  $args = wp_parse_args($args, $defaults);
235
 
236
+ $image = '<img src="https://i.ytimg.com/vi/ID/' . $args['resolution'] . '.jpg" alt="" width="' . $allowed_resolutions[ $args['resolution'] ]['width'] . '" height="' . $allowed_resolutions[ $args['resolution'] ]['height'] . '">';
237
 
238
  if (isset($args['lazy_image']) && $args['lazy_image']) {
239
+ $image = '<img data-lazy-src="https://i.ytimg.com/vi/ID/' . $args['resolution'] . '.jpg" alt="" width="' . $allowed_resolutions[ $args['resolution'] ]['width'] . '" height="' . $allowed_resolutions[ $args['resolution'] ]['height'] . '"><noscript><img src="https://i.ytimg.com/vi/ID/' . $args['resolution'] . '.jpg" alt="" width="' . $allowed_resolutions[ $args['resolution'] ]['width'] . '" height="' . $allowed_resolutions[ $args['resolution'] ]['height'] . '"></noscript>';
240
  }
241
 
242
  return "<script>function lazyLoadThumb(e){var t='{$image}',a='<div class=\"play\"></div>';return t.replace(\"ID\",e)+a}function lazyLoadYoutubeIframe(){var e=document.createElement(\"iframe\"),t=\"https://www.youtube.com/embed/ID?autoplay=1\";t+=0===this.dataset.query.length?'':'&'+this.dataset.query;e.setAttribute(\"src\",t.replace(\"ID\",this.dataset.id)),e.setAttribute(\"frameborder\",\"0\"),e.setAttribute(\"allowfullscreen\",\"1\"),this.parentNode.replaceChild(e,this)}document.addEventListener(\"DOMContentLoaded\",function(){var e,t,a=document.getElementsByClassName(\"rll-youtube-player\");for(t=0;t<a.length;t++)e=document.createElement(\"div\"),e.setAttribute(\"data-id\",a[t].dataset.id),e.setAttribute(\"data-query\", a[t].dataset.query),e.innerHTML=lazyLoadThumb(a[t].dataset.id),e.onclick=lazyLoadYoutubeIframe,a[t].appendChild(e)});</script>";
vendor/wp-media/rocket-lazyload-common/src/Image.php CHANGED
@@ -28,32 +28,12 @@ class Image
28
  $images = array_unique($images, SORT_REGULAR);
29
 
30
  foreach ($images as $image) {
31
- if ($this->isExcluded($image['atts'], $this->getExcludedAttributes())) {
32
- continue;
33
- }
34
-
35
- // Given the previous regex pattern, $image['atts'] starts with a whitespace character.
36
- if (! preg_match('@\ssrc\s*=\s*(\'|")(?<src>.*)\1@iUs', $image['atts'], $atts)) {
37
- continue;
38
- }
39
-
40
- $image['src'] = trim($atts['src']);
41
-
42
- if ('' === $image['src']) {
43
- continue;
44
- }
45
-
46
- if ($this->isExcluded($image['src'], $this->getExcludedSrc())) {
47
  continue;
48
  }
49
 
50
- // Don't apply LazyLoad on images from WP Retina x2.
51
- if (function_exists('wr2x_picture_rewrite')) {
52
- if (wr2x_get_retina(trailingslashit(ABSPATH) . wr2x_get_pathinfo_from_image_src(trim($image['src'], '"')))) {
53
- continue;
54
- }
55
- }
56
-
57
  $image_lazyload = $this->replaceImage($image);
58
  $html = str_replace($image[0], $image_lazyload, $html);
59
 
@@ -72,7 +52,7 @@ class Image
72
  */
73
  public function lazyloadBackgroundImages($html, $buffer)
74
  {
75
- if (! preg_match_all('#<div\s+(?<before>[^>]+[\'"\s])?style\s*=\s*([\'"])(?<styles>.*?)\2(?<after>[^>]*)>#is', $buffer, $elements, PREG_SET_ORDER)) {
76
  return $html;
77
  }
78
 
@@ -93,7 +73,7 @@ class Image
93
 
94
  $lazy_bg = $this->addLazyCLass($element[0]);
95
  $lazy_bg = str_replace($url[0], '', $lazy_bg);
96
- $lazy_bg = str_replace('<div', '<div data-bg="url(' . esc_attr($url['url']) . ')"', $lazy_bg);
97
 
98
  $html = str_replace($element[0], $lazy_bg, $html);
99
  unset($lazy_bg);
@@ -117,7 +97,7 @@ class Image
117
  return $element;
118
  }
119
 
120
- return preg_replace('#<(img|div)([^>]*)>#is', '<\1 class="rocket-lazyload"\2>', $element);
121
  }
122
 
123
  /**
@@ -137,16 +117,16 @@ class Image
137
  $excluded = array_merge($this->getExcludedAttributes(), $this->getExcludedSrc());
138
 
139
  foreach ($pictures as $picture) {
 
 
 
 
140
  if (preg_match_all('#<source(?<atts>\s.+)>#iUs', $picture['sources'], $sources, PREG_SET_ORDER)) {
141
  $sources = array_unique($sources, SORT_REGULAR);
142
 
143
  $lazy_sources = 0;
144
 
145
  foreach ($sources as $source) {
146
- if ($this->isExcluded($source['atts'], $excluded)) {
147
- continue;
148
- }
149
-
150
  $lazyload_srcset = preg_replace('/([\s"\'])srcset/i', '\1data-lazy-srcset', $source[0]);
151
  $html = str_replace($source[0], $lazyload_srcset, $html);
152
 
@@ -159,12 +139,17 @@ class Image
159
  continue;
160
  }
161
 
162
- if (! preg_match('#<img(?:[^>]*)>#is', $picture[0], $img)) {
163
  continue;
164
  }
165
 
166
- $img_lazy = preg_replace('/([\s"\'])srcset/i', '\1data-lazy-src', $img[0]);
 
 
 
 
167
  $img_lazy = $this->addLazyClass($img_lazy);
 
168
  $html = str_replace($img[0], $img_lazy, $html);
169
 
170
  unset($img_lazy);
@@ -173,6 +158,43 @@ class Image
173
  return $html;
174
  }
175
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  /**
177
  * Checks if the provided string matches with the provided excluded patterns
178
  *
@@ -235,6 +257,9 @@ class Image
235
  'loading="lazy"',
236
  'loading="eager"',
237
  'swatch-img',
 
 
 
238
  ]
239
  );
240
  }
@@ -272,8 +297,8 @@ class Image
272
  */
273
  private function replaceImage($image)
274
  {
275
- $width = 1;
276
- $height = 1;
277
 
278
  if (preg_match('@[\s"\']width\s*=\s*(\'|")(?<width>.*)\1@iUs', $image['atts'], $atts)) {
279
  $width = absint($atts['width']);
@@ -417,17 +442,14 @@ class Image
417
  * @since 1.2
418
  * @author Remy Perona
419
  *
420
- * @param int $width Width of the placeholder image. Default 1.
421
- * @param int $height Height of the placeholder image. Default 1.
422
  * @return string
423
  */
424
- public function getPlaceholder($width = 1, $height = 1)
425
  {
426
- $width = absint($width);
427
- $height = absint($height);
428
-
429
- $width = 0 === $width ? 1 : $width;
430
- $height = 0 === $height ? 1 : $height;
431
 
432
  $placeholder = str_replace(' ', '%20', "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 $width $height'%3E%3C/svg%3E");
433
  /**
@@ -436,7 +458,9 @@ class Image
436
  * @since 1.1
437
  *
438
  * @param string $placeholder Placeholder that will be printed.
 
 
439
  */
440
- return apply_filters('rocket_lazyload_placeholder', $placeholder);
441
  }
442
  }
28
  $images = array_unique($images, SORT_REGULAR);
29
 
30
  foreach ($images as $image) {
31
+ $image = $this->canLazyload($image);
32
+
33
+ if (! $image) {
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  continue;
35
  }
36
 
 
 
 
 
 
 
 
37
  $image_lazyload = $this->replaceImage($image);
38
  $html = str_replace($image[0], $image_lazyload, $html);
39
 
52
  */
53
  public function lazyloadBackgroundImages($html, $buffer)
54
  {
55
+ if (! preg_match_all('#<(?<tag>div|section|span|li)\s+(?<before>[^>]+[\'"\s])?style\s*=\s*([\'"])(?<styles>.*?)\3(?<after>[^>]*)>#is', $buffer, $elements, PREG_SET_ORDER)) {
56
  return $html;
57
  }
58
 
73
 
74
  $lazy_bg = $this->addLazyCLass($element[0]);
75
  $lazy_bg = str_replace($url[0], '', $lazy_bg);
76
+ $lazy_bg = str_replace('<' . $element['tag'], '<' . $element['tag'] . ' data-bg="url(' . esc_attr($url['url']) . ')"', $lazy_bg);
77
 
78
  $html = str_replace($element[0], $lazy_bg, $html);
79
  unset($lazy_bg);
97
  return $element;
98
  }
99
 
100
+ return preg_replace('#<(img|div|section|li|span)([^>]*)>#is', '<\1 class="rocket-lazyload"\2>', $element);
101
  }
102
 
103
  /**
117
  $excluded = array_merge($this->getExcludedAttributes(), $this->getExcludedSrc());
118
 
119
  foreach ($pictures as $picture) {
120
+ if ($this->isExcluded($picture[0], $excluded)) {
121
+ continue;
122
+ }
123
+
124
  if (preg_match_all('#<source(?<atts>\s.+)>#iUs', $picture['sources'], $sources, PREG_SET_ORDER)) {
125
  $sources = array_unique($sources, SORT_REGULAR);
126
 
127
  $lazy_sources = 0;
128
 
129
  foreach ($sources as $source) {
 
 
 
 
130
  $lazyload_srcset = preg_replace('/([\s"\'])srcset/i', '\1data-lazy-srcset', $source[0]);
131
  $html = str_replace($source[0], $lazyload_srcset, $html);
132
 
139
  continue;
140
  }
141
 
142
+ if (! preg_match('#<img(?<atts>\s.+)\s?/?>#is', $picture[0], $img)) {
143
  continue;
144
  }
145
 
146
+ if (! $this->canLazyload($img)) {
147
+ continue;
148
+ }
149
+
150
+ $img_lazy = preg_replace('/([\s"\'])src/i', '\1data-lazy-src', $img[0]);
151
  $img_lazy = $this->addLazyClass($img_lazy);
152
+ $img_lazy = apply_filters('rocket_lazyload_html', $img_lazy);
153
  $html = str_replace($img[0], $img_lazy, $html);
154
 
155
  unset($img_lazy);
158
  return $html;
159
  }
160
 
161
+ /**
162
+ * Checks if the image can be lazyloaded
163
+ *
164
+ * @param Array $image Array of image data coming from Regex.
165
+ * @return bool|Array
166
+ */
167
+ private function canLazyload($image)
168
+ {
169
+ if ($this->isExcluded($image['atts'], $this->getExcludedAttributes())) {
170
+ return false;
171
+ }
172
+
173
+ // Given the previous regex pattern, $image['atts'] starts with a whitespace character.
174
+ if (! preg_match('@\ssrc\s*=\s*(\'|")(?<src>.*)\1@iUs', $image['atts'], $atts)) {
175
+ return false;
176
+ }
177
+
178
+ $image['src'] = trim($atts['src']);
179
+
180
+ if ('' === $image['src']) {
181
+ return false;
182
+ }
183
+
184
+ if ($this->isExcluded($image['src'], $this->getExcludedSrc())) {
185
+ return false;
186
+ }
187
+
188
+ // Don't apply LazyLoad on images from WP Retina x2.
189
+ if (function_exists('wr2x_picture_rewrite')) {
190
+ if (wr2x_get_retina(trailingslashit(ABSPATH) . wr2x_get_pathinfo_from_image_src(trim($image['src'], '"')))) {
191
+ return false;
192
+ }
193
+ }
194
+
195
+ return $image;
196
+ }
197
+
198
  /**
199
  * Checks if the provided string matches with the provided excluded patterns
200
  *
257
  'loading="lazy"',
258
  'loading="eager"',
259
  'swatch-img',
260
+ 'data-height-percentage',
261
+ 'data-large_image',
262
+ 'avia-bg-style-fixed',
263
  ]
264
  );
265
  }
297
  */
298
  private function replaceImage($image)
299
  {
300
+ $width = 0;
301
+ $height = 0;
302
 
303
  if (preg_match('@[\s"\']width\s*=\s*(\'|")(?<width>.*)\1@iUs', $image['atts'], $atts)) {
304
  $width = absint($atts['width']);
442
  * @since 1.2
443
  * @author Remy Perona
444
  *
445
+ * @param int $width Width of the placeholder image. Default 0.
446
+ * @param int $height Height of the placeholder image. Default 0.
447
  * @return string
448
  */
449
+ public function getPlaceholder($width = 0, $height = 0)
450
  {
451
+ $width = 0 === $width ? 0 : absint($width);
452
+ $height = 0 === $height ? 0 : absint($height);
 
 
 
453
 
454
  $placeholder = str_replace(' ', '%20', "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 $width $height'%3E%3C/svg%3E");
455
  /**
458
  * @since 1.1
459
  *
460
  * @param string $placeholder Placeholder that will be printed.
461
+ * @param int $width Placeholder width.
462
+ * @param int $height Placeholder height.
463
  */
464
+ return apply_filters('rocket_lazyload_placeholder', $placeholder, $width, $height);
465
  }
466
  }