Lazy Load by WP Rocket - Version 1.4.8

Version Description

  • Notice: Minimum WordPress version required is now 4.7
  • Enhancement: Update lazyload script version
  • Enhancement: Remove placeholder image to improve perceived loading time
  • Enhancement: Compatibility with Youtube privacy URL
  • Enhancement: Update play image to match Youtube logo
  • Enhancement: Support Youtube URL parameters
  • Enhancement: Lazyload images displayed with wp_get_attachment_image(). /!\ no fallback if JavaScript is disabled
  • Fix: Use the correct size set in srcset for the lazyloaded image
  • Fix: Prevent Youtube thumbnail replacement on playlists
  • Fix: Prevent iframe lazyload on AMP pages
  • Fix: Correct text domain for translations (thanks @ Chantal Coolsma)
Download this release

Release Info

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

Code changes from version 1.4.7 to 1.4.8

3rd-party/amp.php CHANGED
@@ -9,8 +9,9 @@ defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );
9
  * @author Remy Perona
10
  */
11
  function rocket_lazyload_disable_on_amp() {
12
- if ( defined( 'AMP_QUERY_VAR' ) && function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
13
  add_filter( 'do_rocket_lazyload', '__return_false' );
 
14
  }
15
  }
16
  add_action( 'wp', 'rocket_lazyload_disable_on_amp' );
9
  * @author Remy Perona
10
  */
11
  function rocket_lazyload_disable_on_amp() {
12
+ if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
13
  add_filter( 'do_rocket_lazyload', '__return_false' );
14
+ add_filter( 'do_rocket_lazyload_iframes', '__return_false' );
15
  }
16
  }
17
  add_action( 'wp', 'rocket_lazyload_disable_on_amp' );
admin/admin.php CHANGED
@@ -53,13 +53,13 @@ function rocket_lazyload_options_output() {
53
 
54
  $options = array(
55
  'images' => array(
56
- 'label' => __( 'Images', 'rocket-lazyload' ),
57
  ),
58
  'iframes' => array(
59
- 'label' => __( 'Iframes & Videos', 'rocket-lazyload' ),
60
  ),
61
  'youtube' => array(
62
- 'label' => __( 'Replace Youtube videos by thumbnail', 'rocket-lazyload' ),
63
  ),
64
  );
65
 
@@ -76,13 +76,13 @@ function rocket_lazyload_options_output() {
76
  <div class="rocket-lazyload-header">
77
  <div>
78
  <p class="rocket-lazyload-title"><img src="<?php echo ROCKET_LL_ASSETS_URL; ?>img/logo.png" srcset="<?php echo ROCKET_LL_ASSETS_URL; ?>img/logo@2x.png 2x" alt="<?php echo esc_attr( get_admin_page_title() ); ?>" width="216" height="59"></p>
79
- <p class="rocket-lazyload-subtitle"><?php _e( 'Settings', 'rocket-lazyload' ); ?></p>
80
  </div>
81
  <?php $rocket_lazyload_rate_url = 'https://wordpress.org/support/plugin/rocket-lazy-load/reviews/?rate=5#postform'; ?>
82
  <p class="rocket-lazyload-rate-us">
83
  <?php
84
  // Translators: %1$s is a <strong> tag, %2$s is </strong><br>, %3$s is the complete link tag to Rocket Lazy Load review form, %4$s is the closing </a> tag.
85
- printf( __( '%1$sDo you like this plugin?%2$s Please take a few seconds to %3$srate it on WordPress.org%4$s!', 'rocket-lazyload' ), '<strong>', '</strong><br>', '<a href="' . $rocket_lazyload_rate_url . '">', '</a>' );
86
  ?>
87
  <br>
88
  <a class="stars" href="<?php echo $rocket_lazyload_rate_url; ?>"><?php echo str_repeat( '<span class="dashicons dashicons-star-filled"></span>', 5 ); ?></a>
@@ -91,9 +91,9 @@ function rocket_lazyload_options_output() {
91
  <div class="rocket-lazyload-body">
92
  <form action="options.php" class="rocket-lazyload-form" method="post">
93
  <fieldset>
94
- <legend class="screen-reader-text"><?php _e( 'Lazyload', 'rocket-lazyload' ); ?></legend>
95
- <p><?php _e( 'LazyLoad displays images, iframes and videos on a page only when they are visible to the user.', 'rocket-lazyload' ); ?></p>
96
- <p><?php _e( 'This mechanism reduces the number of HTTP requests and improves the loading time.', 'rocket-lazyload' ); ?></p>
97
  <ul class="rocket-lazyload-options">
98
  <?php foreach ( $options as $slug => $infos ) { ?>
99
 
@@ -114,30 +114,30 @@ function rocket_lazyload_options_output() {
114
  <div class="rocket-lazyload-upgrade">
115
 
116
  <div class="rocket-lazyload-upgrade-cta">
117
- <p class="rocket-lazyload-subtitle"><?php _e( 'We recommend for you', 'rocket-lazyload' ); ?></p>
118
  <p class="rocket-lazyload-bigtext">
119
- <?php _e( 'Go Premium with', 'rocket-lazyload' ); ?>
120
  <img class="rocket-lazyload-rocket-logo" src="<?php echo ROCKET_LL_ASSETS_URL; ?>img/wprocket.png" srcset="<?php echo ROCKET_LL_ASSETS_URL; ?>img/wprocket@2x.png" width="232" height="63" alt="WP Rocket">
121
  </p>
122
 
123
  <div class="rocket-lazyload-cta-block">
124
- <?php $promo = __( 'Get %s OFF%s Now', 'rocket-lazyload' ); ?>
125
  <?php /*<span class="rocket-lazyload-cta-promo">
126
  <?php printf( $promo, '<strong>20%', '</strong>' ); ?>
127
  </span>*/ ?>
128
- <a class="button button-primary" href="https://wp-rocket.me/?utm_source=wp_plugin&utm_medium=rocket_lazyload"><?php _e( 'Get WP&nbsp;Rocket Now!', 'rocket-lazyload' ); ?></a>
129
  </div>
130
  </div><!-- .rocket-lazyload-upgrade-cta -->
131
 
132
  <div class="rocket-lazyload-upgrade-arguments">
133
  <ul>
134
- <li class="rll-upgrade-item"><?php printf( __( '%sMultiple new features%s to further improve your load time', 'rocket-lazyload' ), '<strong>', '</strong>' ) ?></li>
135
- <li class="rll-upgrade-item"><?php printf( __( 'All you need to %simprove your Google PageSpeed%s score', 'rocket-lazyload' ), '<strong>', '</strong>' ) ?></li>
136
- <li class="rll-upgrade-item"><?php printf( __( '%sBoost your SEO%s by preloading your cache page for Google’s bots', 'rocket-lazyload' ), '<strong>', '</strong>' ) ?></li>
137
- <li class="rll-upgrade-item"><?php printf( __( 'Watch your conversion rise with the %s100%% WooCommerce compatibility%s', 'rocket-lazyload' ), '<strong>', '</strong>' ) ?></li>
138
- <li class="rll-upgrade-item"><?php printf( __( 'Minimal configuration, %sImmediate results%s', 'rocket-lazyload' ), '<strong>', '</strong>' ) ?></li>
139
- <li class="rll-upgrade-item"><?php printf( __( 'Set up takes %s5 minutes flat%s', 'rocket-lazyload' ), '<strong>', '</strong>' ) ?></li>
140
- <li class="rll-upgrade-item"><?php printf( __( '%s24/7 support%s', 'rocket-lazyload' ), '<strong>', '</strong>' ) ?></li>
141
  </ul>
142
  </div><!-- .rocket-lazyload-upgrade-arguments -->
143
 
@@ -146,7 +146,7 @@ function rocket_lazyload_options_output() {
146
 
147
  <p class="submit">
148
  <button type="submit" class="button button-primary">
149
- <span class="text"><?php _e( 'Save changes', 'rocket-lazyload' ); ?></span>
150
  <span class="icon">✓</span>
151
  </button>
152
  </p>
53
 
54
  $options = array(
55
  'images' => array(
56
+ 'label' => __( 'Images', 'rocket-lazy-load' ),
57
  ),
58
  'iframes' => array(
59
+ 'label' => __( 'Iframes &amp; Videos', 'rocket-lazy-load' ),
60
  ),
61
  'youtube' => array(
62
+ 'label' => __( 'Replace Youtube videos by thumbnail', 'rocket-lazy-load' ),
63
  ),
64
  );
65
 
76
  <div class="rocket-lazyload-header">
77
  <div>
78
  <p class="rocket-lazyload-title"><img src="<?php echo ROCKET_LL_ASSETS_URL; ?>img/logo.png" srcset="<?php echo ROCKET_LL_ASSETS_URL; ?>img/logo@2x.png 2x" alt="<?php echo esc_attr( get_admin_page_title() ); ?>" width="216" height="59"></p>
79
+ <p class="rocket-lazyload-subtitle"><?php _e( 'Settings', 'rocket-lazy-load' ); ?></p>
80
  </div>
81
  <?php $rocket_lazyload_rate_url = 'https://wordpress.org/support/plugin/rocket-lazy-load/reviews/?rate=5#postform'; ?>
82
  <p class="rocket-lazyload-rate-us">
83
  <?php
84
  // Translators: %1$s is a <strong> tag, %2$s is </strong><br>, %3$s is the complete link tag to Rocket Lazy Load review form, %4$s is the closing </a> tag.
85
+ printf( __( '%1$sDo you like this plugin?%2$s Please take a few seconds to %3$srate it on WordPress.org%4$s!', 'rocket-lazy-load' ), '<strong>', '</strong><br>', '<a href="' . $rocket_lazyload_rate_url . '">', '</a>' );
86
  ?>
87
  <br>
88
  <a class="stars" href="<?php echo $rocket_lazyload_rate_url; ?>"><?php echo str_repeat( '<span class="dashicons dashicons-star-filled"></span>', 5 ); ?></a>
91
  <div class="rocket-lazyload-body">
92
  <form action="options.php" class="rocket-lazyload-form" method="post">
93
  <fieldset>
94
+ <legend class="screen-reader-text"><?php _e( 'Lazyload', 'rocket-lazy-load' ); ?></legend>
95
+ <p><?php _e( 'LazyLoad displays images, iframes and videos on a page only when they are visible to the user.', 'rocket-lazy-load' ); ?></p>
96
+ <p><?php _e( 'This mechanism reduces the number of HTTP requests and improves the loading time.', 'rocket-lazy-load' ); ?></p>
97
  <ul class="rocket-lazyload-options">
98
  <?php foreach ( $options as $slug => $infos ) { ?>
99
 
114
  <div class="rocket-lazyload-upgrade">
115
 
116
  <div class="rocket-lazyload-upgrade-cta">
117
+ <p class="rocket-lazyload-subtitle"><?php _e( 'We recommend for you', 'rocket-lazy-load' ); ?></p>
118
  <p class="rocket-lazyload-bigtext">
119
+ <?php _e( 'Go Premium with', 'rocket-lazy-load' ); ?>
120
  <img class="rocket-lazyload-rocket-logo" src="<?php echo ROCKET_LL_ASSETS_URL; ?>img/wprocket.png" srcset="<?php echo ROCKET_LL_ASSETS_URL; ?>img/wprocket@2x.png" width="232" height="63" alt="WP Rocket">
121
  </p>
122
 
123
  <div class="rocket-lazyload-cta-block">
124
+ <?php $promo = __( 'Get %s OFF%s Now', 'rocket-lazy-load' ); ?>
125
  <?php /*<span class="rocket-lazyload-cta-promo">
126
  <?php printf( $promo, '<strong>20%', '</strong>' ); ?>
127
  </span>*/ ?>
128
+ <a class="button button-primary" href="https://wp-rocket.me/?utm_source=wp_plugin&utm_medium=rocket_lazyload"><?php _e( 'Get WP&nbsp;Rocket Now!', 'rocket-lazy-load' ); ?></a>
129
  </div>
130
  </div><!-- .rocket-lazyload-upgrade-cta -->
131
 
132
  <div class="rocket-lazyload-upgrade-arguments">
133
  <ul>
134
+ <li class="rll-upgrade-item"><?php printf( __( '%sMultiple new features%s to further improve your load time', 'rocket-lazy-load' ), '<strong>', '</strong>' ) ?></li>
135
+ <li class="rll-upgrade-item"><?php printf( __( 'All you need to %simprove your Google PageSpeed%s score', 'rocket-lazy-load' ), '<strong>', '</strong>' ) ?></li>
136
+ <li class="rll-upgrade-item"><?php printf( __( '%sBoost your SEO%s by preloading your cache page for Google’s bots', 'rocket-lazy-load' ), '<strong>', '</strong>' ) ?></li>
137
+ <li class="rll-upgrade-item"><?php printf( __( 'Watch your conversion rise with the %s100%% WooCommerce compatibility%s', 'rocket-lazy-load' ), '<strong>', '</strong>' ) ?></li>
138
+ <li class="rll-upgrade-item"><?php printf( __( 'Minimal configuration, %sImmediate results%s', 'rocket-lazy-load' ), '<strong>', '</strong>' ) ?></li>
139
+ <li class="rll-upgrade-item"><?php printf( __( 'Set up takes %s5 minutes flat%s', 'rocket-lazy-load' ), '<strong>', '</strong>' ) ?></li>
140
+ <li class="rll-upgrade-item"><?php printf( __( '%s24/7 support%s', 'rocket-lazy-load' ), '<strong>', '</strong>' ) ?></li>
141
  </ul>
142
  </div><!-- .rocket-lazyload-upgrade-arguments -->
143
 
146
 
147
  <p class="submit">
148
  <button type="submit" class="button button-primary">
149
+ <span class="text"><?php _e( 'Save changes', 'rocket-lazy-load' ); ?></span>
150
  <span class="icon">✓</span>
151
  </button>
152
  </p>
admin/notices.php CHANGED
@@ -31,7 +31,7 @@ function rocket_lazyload_imagify_notice() {
31
  ), 'install-plugin_imagify' );
32
 
33
  $classes = ' install-now';
34
- $cta_txt = esc_html__( 'Install Imagify for Free', 'rocket-lazyload' );
35
 
36
  $dismiss_url = wp_nonce_url(
37
  admin_url( 'admin-post.php?action=rocket_lazyload_ignore&box=' . __FUNCTION__ ),
@@ -46,7 +46,7 @@ function rocket_lazyload_imagify_notice() {
46
  <img src="<?php echo ROCKET_LL_ASSETS_URL ?>img/logo-imagify.png" srcset="<?php echo ROCKET_LL_ASSETS_URL ?>img/logo-imagify.svg 2x" alt="Imagify" width="150" height="18">
47
  </p>
48
  <p class="rktll-imagify-msg">
49
- <?php _e( 'Speed up your website and boost your SEO by reducing image file sizes without losing quality with Imagify.', 'rocket-lazyload' ); ?>
50
  </p>
51
  <p class="rktll-imagify-cta">
52
  <a data-slug="imagify" href="<?php echo $action_url; ?>" class="button button-primary<?php echo $classes; ?>"><?php echo $cta_txt; ?></a>
31
  ), 'install-plugin_imagify' );
32
 
33
  $classes = ' install-now';
34
+ $cta_txt = esc_html__( 'Install Imagify for Free', 'rocket-lazy-load' );
35
 
36
  $dismiss_url = wp_nonce_url(
37
  admin_url( 'admin-post.php?action=rocket_lazyload_ignore&box=' . __FUNCTION__ ),
46
  <img src="<?php echo ROCKET_LL_ASSETS_URL ?>img/logo-imagify.png" srcset="<?php echo ROCKET_LL_ASSETS_URL ?>img/logo-imagify.svg 2x" alt="Imagify" width="150" height="18">
47
  </p>
48
  <p class="rktll-imagify-msg">
49
+ <?php _e( 'Speed up your website and boost your SEO by reducing image file sizes without losing quality with Imagify.', 'rocket-lazy-load' ); ?>
50
  </p>
51
  <p class="rktll-imagify-cta">
52
  <a data-slug="imagify" href="<?php echo $action_url; ?>" class="button button-primary<?php echo $classes; ?>"><?php echo $cta_txt; ?></a>
assets/img/youtube.png ADDED
Binary file
assets/js/lazyload-10.8.js ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
2
+
3
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
4
+
5
+ (function (global, factory) {
6
+ (typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.LazyLoad = factory();
7
+ })(this, function () {
8
+ 'use strict';
9
+
10
+ var getInstanceSettings = function getInstanceSettings(customSettings) {
11
+ var defaultSettings = {
12
+ elements_selector: "img",
13
+ container: document,
14
+ threshold: 300,
15
+ data_src: "src",
16
+ data_srcset: "srcset",
17
+ class_loading: "loading",
18
+ class_loaded: "loaded",
19
+ class_error: "error",
20
+ callback_load: null,
21
+ callback_error: null,
22
+ callback_set: null,
23
+ callback_enter: null
24
+ };
25
+
26
+ return _extends({}, defaultSettings, customSettings);
27
+ };
28
+
29
+ var dataPrefix = "data-";
30
+
31
+ var getData = function getData(element, attribute) {
32
+ return element.getAttribute(dataPrefix + attribute);
33
+ };
34
+
35
+ var setData = function setData(element, attribute, value) {
36
+ return element.setAttribute(dataPrefix + attribute, value);
37
+ };
38
+
39
+ var purgeElements = function purgeElements(elements) {
40
+ return elements.filter(function (element) {
41
+ return !getData(element, "was-processed");
42
+ });
43
+ };
44
+
45
+ /* Creates instance and notifies it through the window element */
46
+ var createInstance = function createInstance(classObj, options) {
47
+ var event;
48
+ var eventString = "LazyLoad::Initialized";
49
+ var instance = new classObj(options);
50
+ try {
51
+ // Works in modern browsers
52
+ event = new CustomEvent(eventString, { detail: { instance: instance } });
53
+ } catch (err) {
54
+ // Works in Internet Explorer (all versions)
55
+ event = document.createEvent("CustomEvent");
56
+ event.initCustomEvent(eventString, false, false, { instance: instance });
57
+ }
58
+ window.dispatchEvent(event);
59
+ };
60
+
61
+ /* Auto initialization of one or more instances of lazyload, depending on the
62
+ options passed in (plain object or an array) */
63
+ var autoInitialize = function autoInitialize(classObj, options) {
64
+ if (!options.length) {
65
+ // Plain object
66
+ createInstance(classObj, options);
67
+ } else {
68
+ // Array of objects
69
+ for (var i = 0, optionsItem; optionsItem = options[i]; i += 1) {
70
+ createInstance(classObj, optionsItem);
71
+ }
72
+ }
73
+ };
74
+
75
+ var setSourcesInChildren = function setSourcesInChildren(parentTag, attrName, dataAttrName) {
76
+ for (var i = 0, childTag; childTag = parentTag.children[i]; i += 1) {
77
+ if (childTag.tagName === "SOURCE") {
78
+ var attributeValue = getData(childTag, dataAttrName);
79
+ if (attributeValue) {
80
+ childTag.setAttribute(attrName, attributeValue);
81
+ }
82
+ }
83
+ }
84
+ };
85
+
86
+ var setAttributeIfNotNullOrEmpty = function setAttributeIfNotNullOrEmpty(element, attrName, value) {
87
+ if (!value) {
88
+ return;
89
+ }
90
+ element.setAttribute(attrName, value);
91
+ };
92
+
93
+ var setSources = function setSources(element, settings) {
94
+ var dataAttrSrcName = settings.data_src;
95
+ var elementSrc = getData(element, dataAttrSrcName);
96
+ var tagName = element.tagName;
97
+ if (tagName === "IMG") {
98
+ var dataAttrSrcSetName = settings.data_srcset;
99
+ var elementSrcSet = getData(element, dataAttrSrcSetName);
100
+ var parent = element.parentNode;
101
+ if (parent && parent.tagName === "PICTURE") {
102
+ setSourcesInChildren(parent, "srcset", dataAttrSrcSetName);
103
+ }
104
+ setAttributeIfNotNullOrEmpty(element, "srcset", elementSrcSet);
105
+ setAttributeIfNotNullOrEmpty(element, "src", elementSrc);
106
+ return;
107
+ }
108
+ if (tagName === "IFRAME") {
109
+ setAttributeIfNotNullOrEmpty(element, "src", elementSrc);
110
+ return;
111
+ }
112
+ if (tagName === "VIDEO") {
113
+ setSourcesInChildren(element, "src", dataAttrSrcName);
114
+ setAttributeIfNotNullOrEmpty(element, "src", elementSrc);
115
+ return;
116
+ }
117
+ if (elementSrc) {
118
+ element.style.backgroundImage = 'url("' + elementSrc + '")';
119
+ }
120
+ };
121
+
122
+ var runningOnBrowser = typeof window !== "undefined";
123
+
124
+ var supportsIntersectionObserver = runningOnBrowser && "IntersectionObserver" in window;
125
+
126
+ var supportsClassList = runningOnBrowser && "classList" in document.createElement("p");
127
+
128
+ var addClass = function addClass(element, className) {
129
+ if (supportsClassList) {
130
+ element.classList.add(className);
131
+ return;
132
+ }
133
+ element.className += (element.className ? " " : "") + className;
134
+ };
135
+
136
+ var removeClass = function removeClass(element, className) {
137
+ if (supportsClassList) {
138
+ element.classList.remove(className);
139
+ return;
140
+ }
141
+ element.className = element.className.replace(new RegExp("(^|\\s+)" + className + "(\\s+|$)"), " ").replace(/^\s+/, "").replace(/\s+$/, "");
142
+ };
143
+
144
+ var callCallback = function callCallback(callback, argument) {
145
+ if (callback) {
146
+ callback(argument);
147
+ }
148
+ };
149
+
150
+ var loadString = "load";
151
+ var errorString = "error";
152
+
153
+ var removeListeners = function removeListeners(element, loadHandler, errorHandler) {
154
+ element.removeEventListener(loadString, loadHandler);
155
+ element.removeEventListener(errorString, errorHandler);
156
+ };
157
+
158
+ var addOneShotListeners = function addOneShotListeners(element, settings) {
159
+ var onLoad = function onLoad(event) {
160
+ onEvent(event, true, settings);
161
+ removeListeners(element, onLoad, onError);
162
+ };
163
+ var onError = function onError(event) {
164
+ onEvent(event, false, settings);
165
+ removeListeners(element, onLoad, onError);
166
+ };
167
+ element.addEventListener(loadString, onLoad);
168
+ element.addEventListener(errorString, onError);
169
+ };
170
+
171
+ var onEvent = function onEvent(event, success, settings) {
172
+ var element = event.target;
173
+ removeClass(element, settings.class_loading);
174
+ addClass(element, success ? settings.class_loaded : settings.class_error); // Setting loaded or error class
175
+ callCallback(success ? settings.callback_load : settings.callback_error, element); // Calling loaded or error callback
176
+ };
177
+
178
+ var revealElement = function revealElement(element, settings) {
179
+ callCallback(settings.callback_enter, element);
180
+ if (["IMG", "IFRAME", "VIDEO"].indexOf(element.tagName) > -1) {
181
+ addOneShotListeners(element, settings);
182
+ addClass(element, settings.class_loading);
183
+ }
184
+ setSources(element, settings);
185
+ setData(element, "was-processed", true);
186
+ callCallback(settings.callback_set, element);
187
+ };
188
+
189
+ /* entry.isIntersecting needs fallback because is null on some versions of MS Edge, and
190
+ entry.intersectionRatio is not enough alone because it could be 0 on some intersecting elements */
191
+ var isIntersecting = function isIntersecting(element) {
192
+ return element.isIntersecting || element.intersectionRatio > 0;
193
+ };
194
+
195
+ var LazyLoad = function LazyLoad(customSettings, elements) {
196
+ this._settings = getInstanceSettings(customSettings);
197
+ this._setObserver();
198
+ this.update(elements);
199
+ };
200
+
201
+ LazyLoad.prototype = {
202
+ _setObserver: function _setObserver() {
203
+ var _this = this;
204
+
205
+ if (!supportsIntersectionObserver) {
206
+ return;
207
+ }
208
+
209
+ var settings = this._settings;
210
+ var observerSettings = {
211
+ root: settings.container === document ? null : settings.container,
212
+ rootMargin: settings.threshold + "px"
213
+ };
214
+ var revealIntersectingElements = function revealIntersectingElements(entries) {
215
+ entries.forEach(function (entry) {
216
+ if (isIntersecting(entry)) {
217
+ var element = entry.target;
218
+ revealElement(element, _this._settings);
219
+ _this._observer.unobserve(element);
220
+ }
221
+ });
222
+ _this._elements = purgeElements(_this._elements);
223
+ };
224
+ this._observer = new IntersectionObserver(revealIntersectingElements, observerSettings);
225
+ },
226
+
227
+ loadAll: function loadAll() {
228
+ var settings = this._settings;
229
+ // Fallback: load all elements at once
230
+ this._elements.forEach(function (element) {
231
+ revealElement(element, settings);
232
+ });
233
+ this._elements = purgeElements(this._elements);
234
+ },
235
+
236
+ update: function update(elements) {
237
+ var _this2 = this;
238
+
239
+ var settings = this._settings;
240
+ var nodeSet = elements || settings.container.querySelectorAll(settings.elements_selector);
241
+
242
+ this._elements = purgeElements(Array.prototype.slice.call(nodeSet)); // nodeset to array for IE compatibility
243
+ if (this._observer) {
244
+ this._elements.forEach(function (element) {
245
+ _this2._observer.observe(element);
246
+ });
247
+ return;
248
+ }
249
+ this.loadAll();
250
+ },
251
+
252
+ destroy: function destroy() {
253
+ var _this3 = this;
254
+
255
+ if (this._observer) {
256
+ purgeElements(this._elements).forEach(function (element) {
257
+ _this3._observer.unobserve(element);
258
+ });
259
+ this._observer = null;
260
+ }
261
+ this._elements = null;
262
+ this._settings = null;
263
+ }
264
+ };
265
+
266
+ /* Automatic instances creation if required (useful for async script loading!) */
267
+ var autoInitOptions = window.lazyLoadOptions;
268
+ if (runningOnBrowser && autoInitOptions) {
269
+ autoInitialize(LazyLoad, autoInitOptions);
270
+ }
271
+
272
+ return LazyLoad;
273
+ });
assets/js/lazyload-10.8.min.js ADDED
@@ -0,0 +1 @@
 
1
+ var _extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(e,t){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.LazyLoad=t()}(this,function(){"use strict";var e=function(e){var t={elements_selector:"img",container:document,threshold:300,data_src:"src",data_srcset:"srcset",class_loading:"loading",class_loaded:"loaded",class_error:"error",callback_load:null,callback_error:null,callback_set:null,callback_enter:null};return _extends({},t,e)},t=function(e,t){return e.getAttribute("data-"+t)},n=function(e,t,n){return e.setAttribute("data-"+t,n)},r=function(e){return e.filter(function(e){return!t(e,"was-processed")})},s=function(e,t){var n,r=new e(t);try{n=new CustomEvent("LazyLoad::Initialized",{detail:{instance:r}})}catch(e){(n=document.createEvent("CustomEvent")).initCustomEvent("LazyLoad::Initialized",!1,!1,{instance:r})}window.dispatchEvent(n)},o=function(e,n,r){for(var s,o=0;s=e.children[o];o+=1)if("SOURCE"===s.tagName){var i=t(s,r);i&&s.setAttribute(n,i)}},i=function(e,t,n){n&&e.setAttribute(t,n)},a=function(e,n){var r=n.data_src,s=t(e,r),a=e.tagName;if("IMG"===a){var c=n.data_srcset,l=t(e,c),u=e.parentNode;return u&&"PICTURE"===u.tagName&&o(u,"srcset",c),i(e,"srcset",l),void i(e,"src",s)}if("IFRAME"!==a)return"VIDEO"===a?(o(e,"src",r),void i(e,"src",s)):void(s&&(e.style.backgroundImage='url("'+s+'")'));i(e,"src",s)},c="undefined"!=typeof window,l=c&&"IntersectionObserver"in window,u=c&&"classList"in document.createElement("p"),d=function(e,t){u?e.classList.add(t):e.className+=(e.className?" ":"")+t},f=function(e,t){u?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},v=function(e,t){e&&e(t)},_=function(e,t,n){e.removeEventListener("load",t),e.removeEventListener("error",n)},m=function(e,t){var n=function n(s){b(s,!0,t),_(e,n,r)},r=function r(s){b(s,!1,t),_(e,n,r)};e.addEventListener("load",n),e.addEventListener("error",r)},b=function(e,t,n){var r=e.target;f(r,n.class_loading),d(r,t?n.class_loaded:n.class_error),v(t?n.callback_load:n.callback_error,r)},h=function(e,t){v(t.callback_enter,e),["IMG","IFRAME","VIDEO"].indexOf(e.tagName)>-1&&(m(e,t),d(e,t.class_loading)),a(e,t),n(e,"was-processed",!0),v(t.callback_set,e)},p=function(e){return e.isIntersecting||e.intersectionRatio>0},y=function(t,n){this._settings=e(t),this._setObserver(),this.update(n)};y.prototype={_setObserver:function(){var e=this;if(l){var t=this._settings,n={root:t.container===document?null:t.container,rootMargin:t.threshold+"px"};this._observer=new IntersectionObserver(function(t){t.forEach(function(t){if(p(t)){var n=t.target;h(n,e._settings),e._observer.unobserve(n)}}),e._elements=r(e._elements)},n)}},loadAll:function(){var e=this._settings;this._elements.forEach(function(t){h(t,e)}),this._elements=r(this._elements)},update:function(e){var t=this,n=this._settings,s=e||n.container.querySelectorAll(n.elements_selector);this._elements=r(Array.prototype.slice.call(s)),this._observer?this._elements.forEach(function(e){t._observer.observe(e)}):this.loadAll()},destroy:function(){var e=this;this._observer&&(r(this._elements).forEach(function(t){e._observer.unobserve(t)}),this._observer=null),this._elements=null,this._settings=null}};var g=window.lazyLoadOptions;return c&&g&&function(e,t){if(t.length)for(var n,r=0;n=t[r];r+=1)s(e,n);else s(e,t)}(y,g),y});
assets/js/lazyload-8.9.js ADDED
@@ -0,0 +1,375 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
2
+
3
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
4
+
5
+ (function (global, factory) {
6
+ (typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.LazyLoad = factory();
7
+ })(this, function () {
8
+ 'use strict';
9
+
10
+ var getDefaultSettings = function getDefaultSettings() {
11
+ return {
12
+ elements_selector: "img",
13
+ container: window,
14
+ threshold: 300,
15
+ throttle: 150,
16
+ data_src: "src",
17
+ data_srcset: "srcset",
18
+ class_loading: "loading",
19
+ class_loaded: "loaded",
20
+ class_error: "error",
21
+ class_initial: "initial",
22
+ skip_invisible: true,
23
+ callback_load: null,
24
+ callback_error: null,
25
+ callback_set: null,
26
+ callback_processed: null,
27
+ callback_enter: null
28
+ };
29
+ };
30
+
31
+ var isBot = !("onscroll" in window) || /glebot/.test(navigator.userAgent);
32
+
33
+ var callCallback = function callCallback(callback, argument) {
34
+ if (callback) {
35
+ callback(argument);
36
+ }
37
+ };
38
+
39
+ var getTopOffset = function getTopOffset(element) {
40
+ return element.getBoundingClientRect().top + window.pageYOffset - element.ownerDocument.documentElement.clientTop;
41
+ };
42
+
43
+ var isBelowViewport = function isBelowViewport(element, container, threshold) {
44
+ var fold = container === window ? window.innerHeight + window.pageYOffset : getTopOffset(container) + container.offsetHeight;
45
+ return fold <= getTopOffset(element) - threshold;
46
+ };
47
+
48
+ var getLeftOffset = function getLeftOffset(element) {
49
+ return element.getBoundingClientRect().left + window.pageXOffset - element.ownerDocument.documentElement.clientLeft;
50
+ };
51
+
52
+ var isAtRightOfViewport = function isAtRightOfViewport(element, container, threshold) {
53
+ var documentWidth = window.innerWidth;
54
+ var fold = container === window ? documentWidth + window.pageXOffset : getLeftOffset(container) + documentWidth;
55
+ return fold <= getLeftOffset(element) - threshold;
56
+ };
57
+
58
+ var isAboveViewport = function isAboveViewport(element, container, threshold) {
59
+ var fold = container === window ? window.pageYOffset : getTopOffset(container);
60
+ return fold >= getTopOffset(element) + threshold + element.offsetHeight;
61
+ };
62
+
63
+ var isAtLeftOfViewport = function isAtLeftOfViewport(element, container, threshold) {
64
+ var fold = container === window ? window.pageXOffset : getLeftOffset(container);
65
+ return fold >= getLeftOffset(element) + threshold + element.offsetWidth;
66
+ };
67
+
68
+ var isInsideViewport = function isInsideViewport(element, container, threshold) {
69
+ return !isBelowViewport(element, container, threshold) && !isAboveViewport(element, container, threshold) && !isAtRightOfViewport(element, container, threshold) && !isAtLeftOfViewport(element, container, threshold);
70
+ };
71
+
72
+ /* Creates instance and notifies it through the window element */
73
+ var createInstance = function createInstance(classObj, options) {
74
+ var event;
75
+ var eventString = "LazyLoad::Initialized";
76
+ var instance = new classObj(options);
77
+ try {
78
+ // Works in modern browsers
79
+ event = new CustomEvent(eventString, { detail: { instance: instance } });
80
+ } catch (err) {
81
+ // Works in Internet Explorer (all versions)
82
+ event = document.createEvent("CustomEvent");
83
+ event.initCustomEvent(eventString, false, false, { instance: instance });
84
+ }
85
+ window.dispatchEvent(event);
86
+ };
87
+
88
+ /* Auto initialization of one or more instances of lazyload, depending on the
89
+ options passed in (plain object or an array) */
90
+ var autoInitialize = function autoInitialize(classObj, options) {
91
+ var optsLength = options.length;
92
+ if (!optsLength) {
93
+ // Plain object
94
+ createInstance(classObj, options);
95
+ } else {
96
+ // Array of objects
97
+ for (var i = 0; i < optsLength; i++) {
98
+ createInstance(classObj, options[i]);
99
+ }
100
+ }
101
+ };
102
+
103
+ var dataPrefix = "data-";
104
+
105
+ var getData = function getData(element, attribute) {
106
+ return element.getAttribute(dataPrefix + attribute);
107
+ };
108
+
109
+ var setData = function setData(element, attribute, value) {
110
+ return element.setAttribute(dataPrefix + attribute, value);
111
+ };
112
+
113
+ var setSourcesInChildren = function setSourcesInChildren(parentTag, attrName, dataAttrName) {
114
+ for (var i = 0, childTag; childTag = parentTag.children[i]; i += 1) {
115
+ if (childTag.tagName === "SOURCE") {
116
+ var attributeValue = getData(childTag, dataAttrName);
117
+ if (attributeValue) {
118
+ childTag.setAttribute(attrName, attributeValue);
119
+ }
120
+ }
121
+ }
122
+ };
123
+
124
+ var setAttributeIfNotNullOrEmpty = function setAttributeIfNotNullOrEmpty(element, attrName, value) {
125
+ if (!value) {
126
+ return;
127
+ }
128
+ element.setAttribute(attrName, value);
129
+ };
130
+
131
+ function setSources(element, settings) {
132
+ var dataAttrSrcName = settings.data_src;
133
+ var elementSrc = getData(element, dataAttrSrcName);
134
+ var tagName = element.tagName;
135
+ if (tagName === "IMG") {
136
+ var dataAttrSrcSetName = settings.data_srcset;
137
+ var elementSrcSet = getData(element, dataAttrSrcSetName);
138
+ var parent = element.parentNode;
139
+ if (parent && parent.tagName === "PICTURE") {
140
+ setSourcesInChildren(parent, "srcset", dataAttrSrcSetName);
141
+ }
142
+ setAttributeIfNotNullOrEmpty(element, "srcset", elementSrcSet);
143
+ setAttributeIfNotNullOrEmpty(element, "src", elementSrc);
144
+ return;
145
+ }
146
+ if (tagName === "IFRAME") {
147
+ setAttributeIfNotNullOrEmpty(element, "src", elementSrc);
148
+ return;
149
+ }
150
+ if (tagName === "VIDEO") {
151
+ setSourcesInChildren(element, "src", dataAttrSrcName);
152
+ setAttributeIfNotNullOrEmpty(element, "src", elementSrc);
153
+ return;
154
+ }
155
+ if (elementSrc) {
156
+ element.style.backgroundImage = 'url("' + elementSrc + '")';
157
+ }
158
+ }
159
+
160
+ var runningOnBrowser = typeof window !== "undefined";
161
+
162
+ var supportsClassList = runningOnBrowser && "classList" in document.createElement("p");
163
+
164
+ var addClass = function addClass(element, className) {
165
+ if (supportsClassList) {
166
+ element.classList.add(className);
167
+ return;
168
+ }
169
+ element.className += (element.className ? " " : "") + className;
170
+ };
171
+
172
+ var removeClass = function removeClass(element, className) {
173
+ if (supportsClassList) {
174
+ element.classList.remove(className);
175
+ return;
176
+ }
177
+ element.className = element.className.replace(new RegExp("(^|\\s+)" + className + "(\\s+|$)"), " ").replace(/^\s+/, "").replace(/\s+$/, "");
178
+ };
179
+
180
+ /*
181
+ * Constructor
182
+ */
183
+
184
+ var LazyLoad = function LazyLoad(instanceSettings) {
185
+ this._settings = _extends({}, getDefaultSettings(), instanceSettings);
186
+ this._queryOriginNode = this._settings.container === window ? document : this._settings.container;
187
+
188
+ this._previousLoopTime = 0;
189
+ this._loopTimeout = null;
190
+ this._boundHandleScroll = this.handleScroll.bind(this);
191
+
192
+ this._isFirstLoop = true;
193
+ window.addEventListener("resize", this._boundHandleScroll);
194
+ this.update();
195
+ };
196
+
197
+ LazyLoad.prototype = {
198
+
199
+ /*
200
+ * Private methods
201
+ */
202
+
203
+ _reveal: function _reveal(element) {
204
+ var settings = this._settings;
205
+
206
+ var errorCallback = function errorCallback() {
207
+ /* As this method is asynchronous, it must be protected against external destroy() calls */
208
+ if (!settings) {
209
+ return;
210
+ }
211
+ element.removeEventListener("load", loadCallback);
212
+ element.removeEventListener("error", errorCallback);
213
+ removeClass(element, settings.class_loading);
214
+ addClass(element, settings.class_error);
215
+ callCallback(settings.callback_error, element);
216
+ };
217
+
218
+ var loadCallback = function loadCallback() {
219
+ /* As this method is asynchronous, it must be protected against external destroy() calls */
220
+ if (!settings) {
221
+ return;
222
+ }
223
+ removeClass(element, settings.class_loading);
224
+ addClass(element, settings.class_loaded);
225
+ element.removeEventListener("load", loadCallback);
226
+ element.removeEventListener("error", errorCallback);
227
+ callCallback(settings.callback_load, element);
228
+ };
229
+
230
+ callCallback(settings.callback_enter, element);
231
+ if (["IMG", "IFRAME", "VIDEO"].indexOf(element.tagName) > -1) {
232
+ element.addEventListener("load", loadCallback);
233
+ element.addEventListener("error", errorCallback);
234
+ addClass(element, settings.class_loading);
235
+ }
236
+ setSources(element, settings);
237
+ callCallback(settings.callback_set, element);
238
+ },
239
+
240
+ _loopThroughElements: function _loopThroughElements(forceDownload) {
241
+ var settings = this._settings,
242
+ elements = this._elements,
243
+ elementsLength = !elements ? 0 : elements.length;
244
+ var i = void 0,
245
+ processedIndexes = [],
246
+ firstLoop = this._isFirstLoop;
247
+
248
+ for (i = 0; i < elementsLength; i++) {
249
+ var element = elements[i];
250
+ /* If must skip_invisible and element is invisible, skip it */
251
+ if (settings.skip_invisible && element.offsetParent === null) {
252
+ continue;
253
+ }
254
+
255
+ if (isBot || forceDownload || isInsideViewport(element, settings.container, settings.threshold)) {
256
+ if (firstLoop) {
257
+ addClass(element, settings.class_initial);
258
+ }
259
+ /* Start loading the image */
260
+ this._reveal(element);
261
+ /* Marking the element as processed. */
262
+ processedIndexes.push(i);
263
+ setData(element, "was-processed", true);
264
+ }
265
+ }
266
+ /* Removing processed elements from this._elements. */
267
+ while (processedIndexes.length) {
268
+ elements.splice(processedIndexes.pop(), 1);
269
+ callCallback(settings.callback_processed, elements.length);
270
+ }
271
+ /* Stop listening to scroll event when 0 elements remains */
272
+ if (elementsLength === 0) {
273
+ this._stopScrollHandler();
274
+ }
275
+ /* Sets isFirstLoop to false */
276
+ if (firstLoop) {
277
+ this._isFirstLoop = false;
278
+ }
279
+ },
280
+
281
+ _purgeElements: function _purgeElements() {
282
+ var elements = this._elements,
283
+ elementsLength = elements.length;
284
+ var i = void 0,
285
+ elementsToPurge = [];
286
+
287
+ for (i = 0; i < elementsLength; i++) {
288
+ var element = elements[i];
289
+ /* If the element has already been processed, skip it */
290
+ if (getData(element, "was-processed")) {
291
+ elementsToPurge.push(i);
292
+ }
293
+ }
294
+ /* Removing elements to purge from this._elements. */
295
+ while (elementsToPurge.length > 0) {
296
+ elements.splice(elementsToPurge.pop(), 1);
297
+ }
298
+ },
299
+
300
+ _startScrollHandler: function _startScrollHandler() {
301
+ if (!this._isHandlingScroll) {
302
+ this._isHandlingScroll = true;
303
+ this._settings.container.addEventListener("scroll", this._boundHandleScroll);
304
+ }
305
+ },
306
+
307
+ _stopScrollHandler: function _stopScrollHandler() {
308
+ if (this._isHandlingScroll) {
309
+ this._isHandlingScroll = false;
310
+ this._settings.container.removeEventListener("scroll", this._boundHandleScroll);
311
+ }
312
+ },
313
+
314
+ /*
315
+ * Public methods
316
+ */
317
+
318
+ handleScroll: function handleScroll() {
319
+ var throttle = this._settings.throttle;
320
+
321
+ if (throttle !== 0) {
322
+ var now = Date.now();
323
+ var remainingTime = throttle - (now - this._previousLoopTime);
324
+ if (remainingTime <= 0 || remainingTime > throttle) {
325
+ if (this._loopTimeout) {
326
+ clearTimeout(this._loopTimeout);
327
+ this._loopTimeout = null;
328
+ }
329
+ this._previousLoopTime = now;
330
+ this._loopThroughElements();
331
+ } else if (!this._loopTimeout) {
332
+ this._loopTimeout = setTimeout(function () {
333
+ this._previousLoopTime = Date.now();
334
+ this._loopTimeout = null;
335
+ this._loopThroughElements();
336
+ }.bind(this), remainingTime);
337
+ }
338
+ } else {
339
+ this._loopThroughElements();
340
+ }
341
+ },
342
+
343
+ loadAll: function loadAll() {
344
+ this._loopThroughElements(true);
345
+ },
346
+
347
+ update: function update() {
348
+ // Converts to array the nodeset obtained querying the DOM from _queryOriginNode with elements_selector
349
+ this._elements = Array.prototype.slice.call(this._queryOriginNode.querySelectorAll(this._settings.elements_selector));
350
+ this._purgeElements();
351
+ this._loopThroughElements();
352
+ this._startScrollHandler();
353
+ },
354
+
355
+ destroy: function destroy() {
356
+ window.removeEventListener("resize", this._boundHandleScroll);
357
+ if (this._loopTimeout) {
358
+ clearTimeout(this._loopTimeout);
359
+ this._loopTimeout = null;
360
+ }
361
+ this._stopScrollHandler();
362
+ this._elements = null;
363
+ this._queryOriginNode = null;
364
+ this._settings = null;
365
+ }
366
+ };
367
+
368
+ /* Automatic instances creation if required (useful for async script loading!) */
369
+ var autoInitOptions = window.lazyLoadOptions;
370
+ if (runningOnBrowser && autoInitOptions) {
371
+ autoInitialize(LazyLoad, autoInitOptions);
372
+ }
373
+
374
+ return LazyLoad;
375
+ });
assets/js/lazyload-8.9.min.js ADDED
@@ -0,0 +1 @@
 
1
+ var _extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(e,t){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.LazyLoad=t()}(this,function(){"use strict";function e(e,t){var n=t.data_src,o=h(e,n),i=e.tagName;if("IMG"===i){var s=t.data_srcset,l=h(e,s),r=e.parentNode;return r&&"PICTURE"===r.tagName&&_(r,"srcset",s),p(e,"srcset",l),void p(e,"src",o)}if("IFRAME"!==i)return"VIDEO"===i?(_(e,"src",n),void p(e,"src",o)):void(o&&(e.style.backgroundImage='url("'+o+'")'));p(e,"src",o)}var t=function(){return{elements_selector:"img",container:window,threshold:300,throttle:150,data_src:"src",data_srcset:"srcset",class_loading:"loading",class_loaded:"loaded",class_error:"error",class_initial:"initial",skip_invisible:!0,callback_load:null,callback_error:null,callback_set:null,callback_processed:null,callback_enter:null}},n=!("onscroll"in window)||/glebot/.test(navigator.userAgent),o=function(e,t){e&&e(t)},i=function(e){return e.getBoundingClientRect().top+window.pageYOffset-e.ownerDocument.documentElement.clientTop},s=function(e,t,n){return(t===window?window.innerHeight+window.pageYOffset:i(t)+t.offsetHeight)<=i(e)-n},l=function(e){return e.getBoundingClientRect().left+window.pageXOffset-e.ownerDocument.documentElement.clientLeft},r=function(e,t,n){var o=window.innerWidth;return(t===window?o+window.pageXOffset:l(t)+o)<=l(e)-n},a=function(e,t,n){return(t===window?window.pageYOffset:i(t))>=i(e)+n+e.offsetHeight},c=function(e,t,n){return(t===window?window.pageXOffset:l(t))>=l(e)+n+e.offsetWidth},u=function(e,t,n){return!(s(e,t,n)||a(e,t,n)||r(e,t,n)||c(e,t,n))},d=function(e,t){var n,o=new e(t);try{n=new CustomEvent("LazyLoad::Initialized",{detail:{instance:o}})}catch(e){(n=document.createEvent("CustomEvent")).initCustomEvent("LazyLoad::Initialized",!1,!1,{instance:o})}window.dispatchEvent(n)},h=function(e,t){return e.getAttribute("data-"+t)},f=function(e,t,n){return e.setAttribute("data-"+t,n)},_=function(e,t,n){for(var o,i=0;o=e.children[i];i+=1)if("SOURCE"===o.tagName){var s=h(o,n);s&&o.setAttribute(t,s)}},p=function(e,t,n){n&&e.setAttribute(t,n)},m="undefined"!=typeof window,g=m&&"classList"in document.createElement("p"),v=function(e,t){g?e.classList.add(t):e.className+=(e.className?" ":"")+t},w=function(e,t){g?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},b=function(e){this._settings=_extends({},t(),e),this._queryOriginNode=this._settings.container===window?document:this._settings.container,this._previousLoopTime=0,this._loopTimeout=null,this._boundHandleScroll=this.handleScroll.bind(this),this._isFirstLoop=!0,window.addEventListener("resize",this._boundHandleScroll),this.update()};b.prototype={_reveal:function(t){var n=this._settings,i=function e(){n&&(t.removeEventListener("load",s),t.removeEventListener("error",e),w(t,n.class_loading),v(t,n.class_error),o(n.callback_error,t))},s=function e(){n&&(w(t,n.class_loading),v(t,n.class_loaded),t.removeEventListener("load",e),t.removeEventListener("error",i),o(n.callback_load,t))};o(n.callback_enter,t),["IMG","IFRAME","VIDEO"].indexOf(t.tagName)>-1&&(t.addEventListener("load",s),t.addEventListener("error",i),v(t,n.class_loading)),e(t,n),o(n.callback_set,t)},_loopThroughElements:function(e){var t=this._settings,i=this._elements,s=i?i.length:0,l=void 0,r=[],a=this._isFirstLoop;for(l=0;l<s;l++){var c=i[l];t.skip_invisible&&null===c.offsetParent||(n||e||u(c,t.container,t.threshold))&&(a&&v(c,t.class_initial),this._reveal(c),r.push(l),f(c,"was-processed",!0))}for(;r.length;)i.splice(r.pop(),1),o(t.callback_processed,i.length);0===s&&this._stopScrollHandler(),a&&(this._isFirstLoop=!1)},_purgeElements:function(){var e=this._elements,t=e.length,n=void 0,o=[];for(n=0;n<t;n++){var i=e[n];h(i,"was-processed")&&o.push(n)}for(;o.length>0;)e.splice(o.pop(),1)},_startScrollHandler:function(){this._isHandlingScroll||(this._isHandlingScroll=!0,this._settings.container.addEventListener("scroll",this._boundHandleScroll))},_stopScrollHandler:function(){this._isHandlingScroll&&(this._isHandlingScroll=!1,this._settings.container.removeEventListener("scroll",this._boundHandleScroll))},handleScroll:function(){var e=this._settings.throttle;if(0!==e){var t=Date.now(),n=e-(t-this._previousLoopTime);n<=0||n>e?(this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._previousLoopTime=t,this._loopThroughElements()):this._loopTimeout||(this._loopTimeout=setTimeout(function(){this._previousLoopTime=Date.now(),this._loopTimeout=null,this._loopThroughElements()}.bind(this),n))}else this._loopThroughElements()},loadAll:function(){this._loopThroughElements(!0)},update:function(){this._elements=Array.prototype.slice.call(this._queryOriginNode.querySelectorAll(this._settings.elements_selector)),this._purgeElements(),this._loopThroughElements(),this._startScrollHandler()},destroy:function(){window.removeEventListener("resize",this._boundHandleScroll),this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._stopScrollHandler(),this._elements=null,this._queryOriginNode=null,this._settings=null}};var y=window.lazyLoadOptions;return m&&y&&function(e,t){var n=t.length;if(n)for(var o=0;o<n;o++)d(e,t[o]);else d(e,t)}(b,y),b});
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Lazy Load by WP Rocket ===
2
  Contributors: creativejuiz, tabrisrp, wp_media
3
  Tags: lazyload, lazy load, images, iframes, thumbnail, thumbnails, smiley, smilies, avatar, gravatar
4
- Requires at least: 3.0
5
  Tested up to: 4.9
6
  Requires PHP: 5.3
7
- Stable tag: 1.4.7
8
 
9
  The tiny Lazy Load script for WordPress without jQuery, works for images and iframes.
10
 
@@ -64,6 +64,19 @@ add_filter( 'rocket_lazyload_threshold', 'rocket_lazyload_custom_threshold' );
64
  Some plugins are not compatible without lazy loading. Please open a support thread, and we will see how we can solve the issue by excluding lazy loading for this plugin.
65
 
66
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  = 1.4.7 =
68
  * Fix compatibility with infinite scroll
69
  * Prevent lazyload on masterSlider images
1
  === Lazy Load by WP Rocket ===
2
  Contributors: creativejuiz, tabrisrp, wp_media
3
  Tags: lazyload, lazy load, images, iframes, thumbnail, thumbnails, smiley, smilies, avatar, gravatar
4
+ Requires at least: 4.7
5
  Tested up to: 4.9
6
  Requires PHP: 5.3
7
+ Stable tag: 1.4.8
8
 
9
  The tiny Lazy Load script for WordPress without jQuery, works for images and iframes.
10
 
64
  Some plugins are not compatible without lazy loading. Please open a support thread, and we will see how we can solve the issue by excluding lazy loading for this plugin.
65
 
66
  == Changelog ==
67
+ = 1.4.8 =
68
+ * Notice: Minimum WordPress version required is now 4.7
69
+ * Enhancement: Update lazyload script version
70
+ * Enhancement: Remove placeholder image to improve perceived loading time
71
+ * Enhancement: Compatibility with Youtube privacy URL
72
+ * Enhancement: Update play image to match Youtube logo
73
+ * Enhancement: Support Youtube URL parameters
74
+ * Enhancement: Lazyload images displayed with wp_get_attachment_image(). /!\ no fallback if JavaScript is disabled
75
+ * Fix: Use the correct size set in srcset for the lazyloaded image
76
+ * Fix: Prevent Youtube thumbnail replacement on playlists
77
+ * Fix: Prevent iframe lazyload on AMP pages
78
+ * Fix: Correct text domain for translations (thanks @ Chantal Coolsma)
79
+
80
  = 1.4.7 =
81
  * Fix compatibility with infinite scroll
82
  * Prevent lazyload on masterSlider images
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: 1.4.7
7
  * Author: WP Media
8
  * Author URI: https://wp-rocket.me
9
  * Text Domain: rocket-lazy-load
@@ -24,9 +24,10 @@
24
  * You should have received a copy of the GNU General Public License
25
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
26
  */
 
27
  defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );
28
 
29
- define( 'ROCKET_LL_VERSION', '1.4.7' );
30
  define( 'ROCKET_LL_PATH', realpath( plugin_dir_path( __FILE__ ) ) . '/' );
31
  define( 'ROCKET_LL_3RD_PARTY_PATH', ROCKET_LL_PATH . '3rd-party/' );
32
  define( 'ROCKET_LL_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets/' );
@@ -120,7 +121,7 @@ function rocket_lazyload_script() {
120
  echo '<script>(function(w, d){
121
  var b = d.getElementsByTagName("body")[0];
122
  var s = d.createElement("script"); s.async = true;
123
- var v = !("IntersectionObserver" in w) ? "8.5.2" : "10.3.5";
124
  s.src = "' . ROCKET_LL_FRONT_JS_URL . 'lazyload-" + v + "' . $suffix . '.js";
125
  w.lazyLoadOptions = {
126
  elements_selector: "img, iframe",
@@ -147,7 +148,7 @@ function rocket_lazyload_script() {
147
 
148
  // Listen to the Initialized event
149
  window.addEventListener(\'LazyLoad::Initialized\', function (e) {
150
- // Get the instance and puts it in the lazyLoadInstance variable
151
  var lazyLoadInstance = e.detail.instance;
152
 
153
  var observer = new MutationObserver(function(mutations) {
@@ -164,8 +165,18 @@ window.addEventListener(\'LazyLoad::Initialized\', function (e) {
164
  </script>';
165
 
166
  if ( rocket_lazyload_get_option( 'youtube' ) ) {
 
 
 
 
 
 
 
 
 
 
167
  echo <<<HTML
168
- <script>function lazyLoadThumb(e){var t='<img src="https://i.ytimg.com/vi/ID/hqdefault.jpg">',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";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.innerHTML=lazyLoadThumb(a[t].dataset.id),e.onclick=lazyLoadYoutubeIframe,a[t].appendChild(e)});</script>
169
  HTML;
170
  }
171
  }
@@ -183,7 +194,7 @@ function rocket_lazyload_enqueue() {
183
  }
184
 
185
  if ( rocket_lazyload_get_option( 'youtube' ) ) {
186
- $css = '.rll-youtube-player{position:relative;padding-bottom:56.23%;height:0;overflow:hidden;max-width:100%;background:#000;margin:5px}.rll-youtube-player iframe{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;background:0 0}.rll-youtube-player img{bottom:0;display:block;left:0;margin:auto;max-width:100%;width:100%;position:absolute;right:0;top:0;border:none;height:auto;cursor:pointer;-webkit-transition:.4s all;-moz-transition:.4s all;transition:.4s all}.rll-youtube-player img:hover{-webkit-filter:brightness(75%)}.rll-youtube-player .play{height:72px;width:72px;left:50%;top:50%;margin-left:-36px;margin-top:-36px;position:absolute;background:url(' . ROCKET_LL_ASSETS_URL . 'img/play.png) no-repeat;cursor:pointer}';
187
 
188
  wp_register_style( 'rocket-lazyload', false );
189
  wp_enqueue_style( 'rocket-lazyload' );
@@ -214,10 +225,10 @@ function rocket_lazyload_images( $html ) {
214
 
215
  return preg_replace_callback( '#<img([^>]*) src=("(?:[^"]+)"|\'(?:[^\']+)\'|(?:[^ >]+))([^>]*)>#', 'rocket_lazyload_replace_callback', $html );
216
  }
217
- add_filter( 'get_avatar' , 'rocket_lazyload_images', PHP_INT_MAX );
218
- add_filter( 'the_content' , 'rocket_lazyload_images', PHP_INT_MAX );
219
- add_filter( 'widget_text' , 'rocket_lazyload_images', PHP_INT_MAX );
220
- add_filter( 'get_image_tag' , 'rocket_lazyload_images', PHP_INT_MAX );
221
  add_filter( 'post_thumbnail_html', 'rocket_lazyload_images', PHP_INT_MAX );
222
 
223
  /**
@@ -256,7 +267,7 @@ function rocket_lazyload_replace_callback( $matches ) {
256
  'timthumb.php?src',
257
  ) );
258
 
259
- if ( rocket_is_excluded_lazyload( $matches[1] . $matches[3], $excluded_attributes ) || rocket_is_excluded_lazyload( $matches[2], $excluded_src ) ) {
260
  return $matches[0];
261
  }
262
 
@@ -267,7 +278,7 @@ function rocket_lazyload_replace_callback( $matches ) {
267
  *
268
  * @param string $placeholder Placeholder that will be printed.
269
  */
270
- $placeholder = apply_filters( 'rocket_lazyload_placeholder', 'data:image/gif;base64,R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAEACAkQBADs=' );
271
 
272
  $img = sprintf( '<img%1$s src="%4$s" data-lazy-src=%2$s%3$s>', $matches[1], $matches[2], $matches[3], $placeholder );
273
 
@@ -318,14 +329,46 @@ function rocket_lazyload_on_srcset( $html ) {
318
  $html = str_replace( 'srcset=', 'data-lazy-srcset=', $html );
319
  }
320
 
321
- if ( preg_match( '/sizes=("(?:[^"]+)"|\'(?:[^\']+)\'|(?:[^ >]+))/i', $html ) ) {
322
  $html = str_replace( 'sizes=', 'data-lazy-sizes=', $html );
323
- }
324
 
325
  return $html;
326
  }
327
  add_filter( 'rocket_lazyload_html', 'rocket_lazyload_on_srcset' );
328
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
329
  /**
330
  * Replace WordPress smilies by Lazy Load
331
  *
@@ -352,47 +395,46 @@ add_action( 'init', 'rocket_lazyload_smilies' );
352
  * @source convert_smilies() in /wp-includes/formattings.php
353
  * @since 1.0
354
  *
355
- * @param string $text text content to parse.
356
- * @return string Updated text content
357
  */
358
  function rocket_convert_smilies( $text ) {
359
-
360
  global $wp_smiliessearch;
361
- $output = '';
362
 
363
- if ( get_option( 'use_smilies' ) && ! empty( $wp_smiliessearch ) ) {
364
- // HTML loop taken from texturize function, could possible be consolidated.
365
- $textarr = preg_split( '/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // capture the tags as well as in between.
366
- $stop = count( $textarr );// loop stuff.
367
 
368
- // Ignore proessing of specific tags.
369
- $tags_to_ignore = 'code|pre|style|script|textarea';
370
- $ignore_block_element = '';
 
371
 
372
- for ( $i = 0; $i < $stop; $i++ ) {
373
- $content = $textarr[ $i ];
 
374
 
375
- // If we're in an ignore block, wait until we find its closing tag.
376
- if ( '' === $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')>/', $content, $matches ) ) {
377
- $ignore_block_element = $matches[1];
378
- }
379
 
380
- // If it's not a tag and not in ignore block.
381
- if ( '' === $ignore_block_element && strlen( $content ) > 0 && '<' !== $content[0] ) {
382
- $content = preg_replace_callback( $wp_smiliessearch, 'rocket_translate_smiley', $content );
383
- }
384
 
385
- // did we exit ignore block.
386
- if ( '' !== $ignore_block_element && '</' . $ignore_block_element . '>' === $content ) {
387
- $ignore_block_element = '';
388
- }
389
 
390
- $output .= $content;
 
 
391
  }
392
- } else {
393
- // return default text.
394
- $output = $text;
395
  }
 
396
  return $output;
397
  }
398
 
@@ -402,8 +444,8 @@ function rocket_convert_smilies( $text ) {
402
  * @source translate_smiley() in /wp-includes/formattings.php
403
  * @since 1.0
404
  *
405
- * @param string $matches a string matching the pattern for smilies.
406
- * @return string The updated HTML code to display smilies
407
  */
408
  function rocket_translate_smiley( $matches ) {
409
  global $wpsmiliestrans;
@@ -413,10 +455,10 @@ function rocket_translate_smiley( $matches ) {
413
  }
414
 
415
  $smiley = trim( reset( $matches ) );
416
- $img = $wpsmiliestrans[ $smiley ];
417
 
418
- $matches = array();
419
- $ext = preg_match( '/\.([^.]+)$/', $img, $matches ) ? strtolower( $matches[1] ) : false;
420
  $image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' );
421
 
422
  // Don't convert smilies that aren't images - they're probably emoji.
@@ -427,7 +469,7 @@ function rocket_translate_smiley( $matches ) {
427
  /**
428
  * Filter the Smiley image URL before it's used in the image element.
429
  *
430
- * @since WP 2.9.0
431
  *
432
  * @param string $smiley_url URL for the smiley image.
433
  * @param string $img Filename for the smiley image.
@@ -435,13 +477,15 @@ function rocket_translate_smiley( $matches ) {
435
  */
436
  $src_url = apply_filters( 'smilies_src', includes_url( "images/smilies/$img" ), $img, site_url() );
437
 
438
- // Don't lazy-load if process is stopped with a hook.
439
- if ( apply_filters( 'do_rocket_lazyload', true ) ) {
440
- return sprintf( ' <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" data-lazy-original="%s" alt="%s" class="wp-smiley" /> ', esc_url( $src_url ), esc_attr( $smiley ) );
441
- } else {
442
  return sprintf( ' <img src="%s" alt="%s" class="wp-smiley" /> ', esc_url( $src_url ), esc_attr( $smiley ) );
443
  }
444
 
 
 
 
 
445
  }
446
 
447
  /**
@@ -459,8 +503,7 @@ function rocket_lazyload_iframes( $html ) {
459
  return $html;
460
  }
461
 
462
- $matches = array();
463
- preg_match_all( '/<iframe(?:.*)?src=["|\'](.*)["|\'](?:.*)?><\/iframe>/iU', $html, $matches, PREG_SET_ORDER );
464
 
465
  if ( empty( $matches ) ) {
466
  return $html;
@@ -484,6 +527,8 @@ function rocket_lazyload_iframes( $html ) {
484
  continue;
485
  }
486
 
 
 
487
  /**
488
  * Filter the LazyLoad HTML output on Youtube iframes
489
  *
@@ -491,34 +536,39 @@ function rocket_lazyload_iframes( $html ) {
491
  *
492
  * @param array $html Output that will be printed.
493
  */
494
- $youtube_lazyload = apply_filters( 'rocket_lazyload_youtube_html', '<div class="rll-youtube-player" data-id="' . $youtube_id . '"></div>');
495
  $youtube_lazyload .= '<noscript>' . $iframe[0] . '</noscript>';
496
 
497
  $html = str_replace( $iframe[0], $youtube_lazyload, $html );
498
- } else {
499
- /**
500
- * Filter the LazyLoad placeholder on src attribute
501
- *
502
- * @since 1.1
503
- *
504
- * @param string $placeholder placeholder that will be printed.
505
- */
506
- $placeholder = apply_filters( 'rocket_lazyload_placeholder', 'about:blank' );
507
-
508
- $iframe_noscript = '<noscript>' . $iframe[0] . '</noscript>';
509
 
510
- /**
511
- * Filter the LazyLoad HTML output on iframes
512
- *
513
- * @since 1.1
514
- *
515
- * @param array $html Output that will be printed.
516
- */
517
- $iframe_lazyload = apply_filters( 'rocket_lazyload_iframe_html', str_replace( $iframe[1], $placeholder . '" data-rocket-lazyload="fitvidscompatible" data-lazy-src="' . $iframe[1], $iframe[0] ) );
518
- $iframe_lazyload .= $iframe_noscript;
519
-
520
- $html = str_replace( $iframe[0], $iframe_lazyload, $html );
521
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
522
  }
523
 
524
  return $html;
@@ -536,11 +586,16 @@ add_filter( 'widget_text', 'rocket_lazyload_iframes', PHP_INT_MAX );
536
  * @return string Youtube video id or false if none found.
537
  */
538
  function rocket_lazyload_get_youtube_id_from_url( $url ) {
539
- $pattern = '#^(?:https?://)?(?:www\.)?(?:youtu\.be/|youtube\.com(?:/embed/|/v/|/watch\?v=))([\w-]{11})#iU';
540
  $result = preg_match( $pattern, $url, $matches );
541
 
542
- if ( $result ) {
543
- return $matches[1];
544
  }
545
- return false;
 
 
 
 
 
546
  }
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: 1.4.8
7
  * Author: WP Media
8
  * Author URI: https://wp-rocket.me
9
  * Text Domain: rocket-lazy-load
24
  * You should have received a copy of the GNU General Public License
25
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
26
  */
27
+
28
  defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );
29
 
30
+ define( 'ROCKET_LL_VERSION', '1.4.8' );
31
  define( 'ROCKET_LL_PATH', realpath( plugin_dir_path( __FILE__ ) ) . '/' );
32
  define( 'ROCKET_LL_3RD_PARTY_PATH', ROCKET_LL_PATH . '3rd-party/' );
33
  define( 'ROCKET_LL_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets/' );
121
  echo '<script>(function(w, d){
122
  var b = d.getElementsByTagName("body")[0];
123
  var s = d.createElement("script"); s.async = true;
124
+ var v = !("IntersectionObserver" in w) ? "8.9" : "10.8";
125
  s.src = "' . ROCKET_LL_FRONT_JS_URL . 'lazyload-" + v + "' . $suffix . '.js";
126
  w.lazyLoadOptions = {
127
  elements_selector: "img, iframe",
148
 
149
  // Listen to the Initialized event
150
  window.addEventListener(\'LazyLoad::Initialized\', function (e) {
151
+ // Get the instance and puts it in the lazyLoadInstance variable
152
  var lazyLoadInstance = e.detail.instance;
153
 
154
  var observer = new MutationObserver(function(mutations) {
165
  </script>';
166
 
167
  if ( rocket_lazyload_get_option( 'youtube' ) ) {
168
+ /**
169
+ * Filters the resolution of the YouTube thumbnail
170
+ *
171
+ * @since 1.4.8
172
+ * @author Arun Basil Lal
173
+ *
174
+ * @param string $thumbnail_resolution The resolution of the thumbnail. Accepted values: default, mqdefault, sddefault, hqdefault, maxresdefault
175
+ */
176
+ $thumbnail_resolution = apply_filters( 'rocket_youtube_thumbnail_resolution', 'hqdefault' );
177
+
178
  echo <<<HTML
179
+ <script>function lazyLoadThumb(e){var t='<img src="https://i.ytimg.com/vi/ID/$thumbnail_resolution.jpg">',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>
180
  HTML;
181
  }
182
  }
194
  }
195
 
196
  if ( rocket_lazyload_get_option( 'youtube' ) ) {
197
+ $css = '.rll-youtube-player{position:relative;padding-bottom:56.23%;height:0;overflow:hidden;max-width:100%;background:#000;margin:5px}.rll-youtube-player iframe{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;background:0 0}.rll-youtube-player img{bottom:0;display:block;left:0;margin:auto;max-width:100%;width:100%;position:absolute;right:0;top:0;border:none;height:auto;cursor:pointer;-webkit-transition:.4s all;-moz-transition:.4s all;transition:.4s all}.rll-youtube-player img:hover{-webkit-filter:brightness(75%)}.rll-youtube-player .play{height:72px;width:72px;left:50%;top:50%;margin-left:-36px;margin-top:-36px;position:absolute;background:url(' . ROCKET_LL_ASSETS_URL . 'img/youtube.png) no-repeat;cursor:pointer}';
198
 
199
  wp_register_style( 'rocket-lazyload', false );
200
  wp_enqueue_style( 'rocket-lazyload' );
225
 
226
  return preg_replace_callback( '#<img([^>]*) src=("(?:[^"]+)"|\'(?:[^\']+)\'|(?:[^ >]+))([^>]*)>#', 'rocket_lazyload_replace_callback', $html );
227
  }
228
+ add_filter( 'get_avatar', 'rocket_lazyload_images', PHP_INT_MAX );
229
+ add_filter( 'the_content', 'rocket_lazyload_images', PHP_INT_MAX );
230
+ add_filter( 'widget_text', 'rocket_lazyload_images', PHP_INT_MAX );
231
+ add_filter( 'get_image_tag', 'rocket_lazyload_images', PHP_INT_MAX );
232
  add_filter( 'post_thumbnail_html', 'rocket_lazyload_images', PHP_INT_MAX );
233
 
234
  /**
267
  'timthumb.php?src',
268
  ) );
269
 
270
+ if ( rocket_is_excluded_lazyload( $matches[1] . $matches[3], $excluded_attributes ) || rocket_is_excluded_lazyload( $matches[2], $excluded_src ) ) {
271
  return $matches[0];
272
  }
273
 
278
  *
279
  * @param string $placeholder Placeholder that will be printed.
280
  */
281
+ $placeholder = apply_filters( 'rocket_lazyload_placeholder', '' );
282
 
283
  $img = sprintf( '<img%1$s src="%4$s" data-lazy-src=%2$s%3$s>', $matches[1], $matches[2], $matches[3], $placeholder );
284
 
329
  $html = str_replace( 'srcset=', 'data-lazy-srcset=', $html );
330
  }
331
 
332
+ /**if ( preg_match( '/sizes=("(?:[^"]+)"|\'(?:[^\']+)\'|(?:[^ >]+))/i', $html ) ) {
333
  $html = str_replace( 'sizes=', 'data-lazy-sizes=', $html );
334
+ }*/
335
 
336
  return $html;
337
  }
338
  add_filter( 'rocket_lazyload_html', 'rocket_lazyload_on_srcset' );
339
 
340
+ /**
341
+ * Applies lazyload on images displayed using wp_get_attachment_image()
342
+ *
343
+ * @since 1.4.8
344
+ * @author Remy Perona
345
+ *
346
+ * @param array $attr Attributes for the image markup.
347
+ * @return array
348
+ */
349
+ function rocket_lazyload_get_attachment_image( $attr ) {
350
+ // Don't LazyLoad if the thumbnail is in admin, a feed, REST API or a post preview.
351
+ if ( ! rocket_lazyload_get_option( 'images' ) || is_admin() || is_feed() || is_preview() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) || empty( $attr ) || ( defined( 'DONOTLAZYLOAD' ) && DONOTLAZYLOAD ) || wp_script_is( 'twentytwenty-twentytwenty', 'enqueued' ) ) {
352
+ return $attr;
353
+ }
354
+
355
+ // You can stop the LalyLoad process with a hook.
356
+ if ( ! apply_filters( 'do_rocket_lazyload', true ) ) {
357
+ return $attr;
358
+ }
359
+
360
+ $attr['data-lazy-src'] = $attr['src'];
361
+ $attr['src'] = apply_filters( 'rocket_lazyload_placeholder', '' );
362
+
363
+ if ( isset( $attr['srcset'] ) ) {
364
+ $attr['data-lazy-srcset'] = $attr['srcset'];
365
+ unset( $attr['srcset'] );
366
+ }
367
+
368
+ return $attr;
369
+ }
370
+ add_filter( 'wp_get_attachment_image_attributes', 'rocket_lazyload_get_attachment_image' );
371
+
372
  /**
373
  * Replace WordPress smilies by Lazy Load
374
  *
395
  * @source convert_smilies() in /wp-includes/formattings.php
396
  * @since 1.0
397
  *
398
+ * @param string $text Text to process.
399
+ * @return string Modified text
400
  */
401
  function rocket_convert_smilies( $text ) {
 
402
  global $wp_smiliessearch;
 
403
 
404
+ if ( ! get_option( 'use_smilies' ) || empty( $wp_smiliessearch ) ) {
405
+ return $text;
406
+ }
 
407
 
408
+ $output = '';
409
+ // HTML loop taken from texturize function, could possible be consolidated.
410
+ $textarr = preg_split( '/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // capture the tags as well as in between.
411
+ $stop = count( $textarr );// loop stuff.
412
 
413
+ // Ignore proessing of specific tags.
414
+ $tags_to_ignore = 'code|pre|style|script|textarea';
415
+ $ignore_block_element = '';
416
 
417
+ for ( $i = 0; $i < $stop; $i++ ) {
418
+ $content = $textarr[ $i ];
 
 
419
 
420
+ // If we're in an ignore block, wait until we find its closing tag.
421
+ if ( '' === $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')>/', $content, $matches ) ) {
422
+ $ignore_block_element = $matches[1];
423
+ }
424
 
425
+ // If it's not a tag and not in ignore block.
426
+ if ( '' === $ignore_block_element && strlen( $content ) > 0 && '<' !== $content[0] ) {
427
+ $content = preg_replace_callback( $wp_smiliessearch, 'rocket_translate_smiley', $content );
428
+ }
429
 
430
+ // did we exit ignore block.
431
+ if ( '' !== $ignore_block_element && '</' . $ignore_block_element . '>' === $content ) {
432
+ $ignore_block_element = '';
433
  }
434
+
435
+ $output .= $content;
 
436
  }
437
+
438
  return $output;
439
  }
440
 
444
  * @source translate_smiley() in /wp-includes/formattings.php
445
  * @since 1.0
446
  *
447
+ * @param array $matches An array of matching content.
448
+ * @return string HTML code for smiley
449
  */
450
  function rocket_translate_smiley( $matches ) {
451
  global $wpsmiliestrans;
455
  }
456
 
457
  $smiley = trim( reset( $matches ) );
458
+ $img = $wpsmiliestrans[ $smiley ];
459
 
460
+ $matches = array();
461
+ $ext = preg_match( '/\.([^.]+)$/', $img, $matches ) ? strtolower( $matches[1] ) : false;
462
  $image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' );
463
 
464
  // Don't convert smilies that aren't images - they're probably emoji.
469
  /**
470
  * Filter the Smiley image URL before it's used in the image element.
471
  *
472
+ * @since 2.9.0
473
  *
474
  * @param string $smiley_url URL for the smiley image.
475
  * @param string $img Filename for the smiley image.
477
  */
478
  $src_url = apply_filters( 'smilies_src', includes_url( "images/smilies/$img" ), $img, site_url() );
479
 
480
+ // Don't LazyLoad if process is stopped for these reasons.
481
+ if ( ! apply_filters( 'do_rocket_lazyload', true ) || is_feed() || is_preview() ) {
 
 
482
  return sprintf( ' <img src="%s" alt="%s" class="wp-smiley" /> ', esc_url( $src_url ), esc_attr( $smiley ) );
483
  }
484
 
485
+ /** This filter is documented in inc/front/lazyload.php */
486
+ $placeholder = apply_filters( 'rocket_lazyload_placeholder', '' );
487
+
488
+ return sprintf( ' <img src="%s" data-lazy-src="%s" alt="%s" class="wp-smiley" /> ', $placeholder, esc_url( $src_url ), esc_attr( $smiley ) );
489
  }
490
 
491
  /**
503
  return $html;
504
  }
505
 
506
+ preg_match_all( '/<iframe.*\ssrc=["|\'](.+)["|\'].*(>\s*<\/iframe>)/iU', $html, $matches, PREG_SET_ORDER );
 
507
 
508
  if ( empty( $matches ) ) {
509
  return $html;
527
  continue;
528
  }
529
 
530
+ $query = wp_parse_url( $iframe[1], PHP_URL_QUERY );
531
+
532
  /**
533
  * Filter the LazyLoad HTML output on Youtube iframes
534
  *
536
  *
537
  * @param array $html Output that will be printed.
538
  */
539
+ $youtube_lazyload = apply_filters( 'rocket_lazyload_youtube_html', '<div class="rll-youtube-player" data-id="' . esc_attr( $youtube_id ) . '" data-query="' . esc_attr( $query ) . '"></div>' );
540
  $youtube_lazyload .= '<noscript>' . $iframe[0] . '</noscript>';
541
 
542
  $html = str_replace( $iframe[0], $youtube_lazyload, $html );
 
 
 
 
 
 
 
 
 
 
 
543
 
544
+ continue;
 
 
 
 
 
 
 
 
 
 
545
  }
546
+
547
+ /**
548
+ * Filter the LazyLoad placeholder on src attribute
549
+ *
550
+ * @since 1.1
551
+ *
552
+ * @param string $placeholder placeholder that will be printed.
553
+ */
554
+ $placeholder = apply_filters( 'rocket_lazyload_placeholder', 'about:blank' );
555
+
556
+ $iframe_noscript = '<noscript>' . $iframe[0] . '</noscript>';
557
+
558
+ $iframe_lazyload = str_replace( $iframe[1], $placeholder, $iframe[0] );
559
+
560
+ $iframe_lazyload = str_replace( $iframe[2], ' data-rocket-lazyload="fitvidscompatible" data-lazy-src="' . esc_url( $iframe[1] ) . '"' . $iframe[2], $iframe[0] );
561
+ /**
562
+ * Filter the LazyLoad HTML output on iframes
563
+ *
564
+ * @since 1.1
565
+ *
566
+ * @param array $html Output that will be printed.
567
+ */
568
+ $iframe_lazyload = apply_filters( 'rocket_lazyload_iframe_html', $iframe_lazyload );
569
+ $iframe_lazyload .= $iframe_noscript;
570
+
571
+ $html = str_replace( $iframe[0], $iframe_lazyload, $html );
572
  }
573
 
574
  return $html;
586
  * @return string Youtube video id or false if none found.
587
  */
588
  function rocket_lazyload_get_youtube_id_from_url( $url ) {
589
+ $pattern = '#^(?:https?://)?(?:www\.)?(?:youtu\.be|youtube\.com|youtube-nocookie\.com)/(?:embed/|v/|watch/?\?v=)([\w-]{11})#iU';
590
  $result = preg_match( $pattern, $url, $matches );
591
 
592
+ if ( ! $result ) {
593
+ return false;
594
  }
595
+
596
+ if ( 'videoseries' === $matches[1] ) {
597
+ return false;
598
+ }
599
+
600
+ return $matches[1];
601
  }