Version Description
Maintenance Update. 2 code tweaks and 2 bug fixes to correct lazy load not showing WordPress v 4.4 Responsive Images in legacy and mobile browsers, should flush the cached if site have installed cache plugin
Download this release
Release Info
Developer | a3rev |
Plugin | a3 Lazy Load |
Version | 1.5.2 |
Comparing to | |
See all releases |
Code changes from version 1.5.1 to 1.5.2
- a3-lazy-load.php +2 -2
- admin/a3-lazy-load-admin.php +2 -2
- admin/less/sass.php +1 -1
- assets/js/jquery.lazyloadxt.srcset.js +118 -0
- assets/js/jquery.lazyloadxt.srcset.min.js +2 -0
- classes/class-a3-lazy-load.php +25 -3
- readme.txt +10 -1
a3-lazy-load.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: a3 Lazy Load
|
4 |
Description: Speed up your site and enhance frontend user's visual experience in PC's, Tablets and mobile with a3 Lazy Load.
|
5 |
-
Version: 1.5.
|
6 |
Author: a3 Revolution
|
7 |
Author URI: http://www.a3rev.com/
|
8 |
Requires at least: 3.8
|
@@ -17,7 +17,7 @@ License: GPLv2 or later
|
|
17 |
*/
|
18 |
?>
|
19 |
<?php
|
20 |
-
define('A3_LAZY_VERSION', '1.2
|
21 |
define('A3_LAZY_LOAD_FILE_PATH', dirname(__FILE__));
|
22 |
define('A3_LAZY_LOAD_DIR_NAME', basename(A3_LAZY_LOAD_FILE_PATH));
|
23 |
define('A3_LAZY_LOAD_FOLDER', dirname(plugin_basename(__FILE__)));
|
2 |
/*
|
3 |
Plugin Name: a3 Lazy Load
|
4 |
Description: Speed up your site and enhance frontend user's visual experience in PC's, Tablets and mobile with a3 Lazy Load.
|
5 |
+
Version: 1.5.2
|
6 |
Author: a3 Revolution
|
7 |
Author URI: http://www.a3rev.com/
|
8 |
Requires at least: 3.8
|
17 |
*/
|
18 |
?>
|
19 |
<?php
|
20 |
+
define('A3_LAZY_VERSION', '1.5.2');
|
21 |
define('A3_LAZY_LOAD_FILE_PATH', dirname(__FILE__));
|
22 |
define('A3_LAZY_LOAD_DIR_NAME', basename(A3_LAZY_LOAD_FILE_PATH));
|
23 |
define('A3_LAZY_LOAD_FOLDER', dirname(plugin_basename(__FILE__)));
|
admin/a3-lazy-load-admin.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
update_option('a3rev_lazy_load_plugin', 'a3_lazy_load');
|
3 |
|
4 |
function a3_lazy_load_activated(){
|
5 |
-
update_option('a3_lazy_load_version', '1.5.
|
6 |
|
7 |
// Set Settings Default from Admin Init
|
8 |
global $a3_lazy_load_admin_init;
|
@@ -59,6 +59,6 @@ function a3_lazy_load_upgrade_plugin() {
|
|
59 |
include( A3_LAZY_LOAD_DIR. '/includes/updates/a3-lazy-load-update-1.1.0.php' );
|
60 |
}
|
61 |
|
62 |
-
update_option('a3_lazy_load_version', '1.5.
|
63 |
}
|
64 |
?>
|
2 |
update_option('a3rev_lazy_load_plugin', 'a3_lazy_load');
|
3 |
|
4 |
function a3_lazy_load_activated(){
|
5 |
+
update_option('a3_lazy_load_version', '1.5.2');
|
6 |
|
7 |
// Set Settings Default from Admin Init
|
8 |
global $a3_lazy_load_admin_init;
|
59 |
include( A3_LAZY_LOAD_DIR. '/includes/updates/a3-lazy-load-update-1.1.0.php' );
|
60 |
}
|
61 |
|
62 |
+
update_option('a3_lazy_load_version', '1.5.2');
|
63 |
}
|
64 |
?>
|
admin/less/sass.php
CHANGED
@@ -23,7 +23,7 @@ class A3_Lazy_Load_Less
|
|
23 |
{
|
24 |
$_upload_dir = wp_upload_dir();
|
25 |
if ( file_exists( $_upload_dir['basedir'] . '/sass/' . $this->css_file_name . '.min.css' ) ) {
|
26 |
-
wp_enqueue_style( 'a3' . $this->css_file_name, str_replace( array('http:','https:'), '', $_upload_dir['baseurl'] ) . '/sass/' . $this->css_file_name . '.min.css', array() );
|
27 |
}
|
28 |
}
|
29 |
|
23 |
{
|
24 |
$_upload_dir = wp_upload_dir();
|
25 |
if ( file_exists( $_upload_dir['basedir'] . '/sass/' . $this->css_file_name . '.min.css' ) ) {
|
26 |
+
wp_enqueue_style( 'a3' . $this->css_file_name, str_replace( array('http:','https:'), '', $_upload_dir['baseurl'] ) . '/sass/' . $this->css_file_name . '.min.css', array(), A3_LAZY_VERSION );
|
27 |
}
|
28 |
}
|
29 |
|
assets/js/jquery.lazyloadxt.srcset.js
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*! Lazy Load XT v1.0.6 2014-11-19
|
2 |
+
* http://ressio.github.io/lazy-load-xt
|
3 |
+
* (C) 2014 RESS.io
|
4 |
+
* Licensed under MIT */
|
5 |
+
|
6 |
+
(function ($, window, document, undefined) {
|
7 |
+
var options = $.lazyLoadXT,
|
8 |
+
srcsetSupport = (function () {
|
9 |
+
return 'srcset' in (new Image());
|
10 |
+
})(),
|
11 |
+
reUrl = /^\s*(\S*)/,
|
12 |
+
reWidth = /\S\s+(\d+)w/,
|
13 |
+
reHeight = /\S\s+(\d+)h/,
|
14 |
+
reDpr = /\S\s+([\d\.]+)x/,
|
15 |
+
infty = [0, Infinity],
|
16 |
+
one = [0, 1],
|
17 |
+
srcsetOptions = {
|
18 |
+
srcsetAttr: 'data-srcset',
|
19 |
+
srcsetExtended: false,
|
20 |
+
srcsetBaseAttr: 'data-srcset-base',
|
21 |
+
srcsetExtAttr: 'data-srcset-ext'
|
22 |
+
},
|
23 |
+
viewport = {
|
24 |
+
w: 0,
|
25 |
+
h: 0,
|
26 |
+
x: 0
|
27 |
+
},
|
28 |
+
property,
|
29 |
+
limit;
|
30 |
+
|
31 |
+
for (property in srcsetOptions) {
|
32 |
+
if (options[property] === undefined) {
|
33 |
+
options[property] = srcsetOptions[property];
|
34 |
+
}
|
35 |
+
}
|
36 |
+
options.selector += ',img[' + options.srcsetAttr + ']';
|
37 |
+
|
38 |
+
function mathFilter(array, action) {
|
39 |
+
return Math[action].apply(null, $.map(array, function (item) {
|
40 |
+
return item[property];
|
41 |
+
}));
|
42 |
+
}
|
43 |
+
|
44 |
+
function compareMax(item) {
|
45 |
+
return item[property] >= viewport[property] || item[property] === limit;
|
46 |
+
}
|
47 |
+
|
48 |
+
function compareMin(item) {
|
49 |
+
return item[property] === limit;
|
50 |
+
}
|
51 |
+
|
52 |
+
function parseSrcset($el) {
|
53 |
+
var srcset = $el.attr(options.srcsetAttr);
|
54 |
+
|
55 |
+
if (!srcset) {
|
56 |
+
return false;
|
57 |
+
}
|
58 |
+
|
59 |
+
var list = $.map(srcset.split(','), function (item) {
|
60 |
+
return {
|
61 |
+
url: reUrl.exec(item)[1],
|
62 |
+
w: parseFloat((reWidth.exec(item) || infty)[1]),
|
63 |
+
h: parseFloat((reHeight.exec(item) || infty)[1]),
|
64 |
+
x: parseFloat((reDpr.exec(item) || one)[1])
|
65 |
+
};
|
66 |
+
});
|
67 |
+
|
68 |
+
if (!list.length) {
|
69 |
+
return false;
|
70 |
+
}
|
71 |
+
|
72 |
+
var documentElement = document.documentElement,
|
73 |
+
whx,
|
74 |
+
src;
|
75 |
+
|
76 |
+
viewport = {
|
77 |
+
w: window.innerWidth || documentElement.clientWidth,
|
78 |
+
h: window.innerHeight || documentElement.clientHeight,
|
79 |
+
x: window.devicePixelRatio || 1
|
80 |
+
};
|
81 |
+
|
82 |
+
// Notice for DOMtastic users: currently $.grep method is not implemented in DOMtastic
|
83 |
+
|
84 |
+
for (whx in viewport) {
|
85 |
+
property = whx;
|
86 |
+
limit = mathFilter(list, 'max');
|
87 |
+
list = $.grep(list, compareMax);
|
88 |
+
}
|
89 |
+
|
90 |
+
for (whx in viewport) {
|
91 |
+
property = whx;
|
92 |
+
limit = mathFilter(list, 'min');
|
93 |
+
list = $.grep(list, compareMin);
|
94 |
+
}
|
95 |
+
|
96 |
+
src = list[0].url;
|
97 |
+
|
98 |
+
if (options.srcsetExtended) {
|
99 |
+
src = ($el.attr(options.srcsetBaseAttr) || '') + src + ($el.attr(options.srcsetExtAttr) || '');
|
100 |
+
}
|
101 |
+
|
102 |
+
return src;
|
103 |
+
}
|
104 |
+
|
105 |
+
$(document).on('lazyshow', 'img', function (e, $el) {
|
106 |
+
var srcset = $el.attr(options.srcsetAttr);
|
107 |
+
|
108 |
+
if (srcset) {
|
109 |
+
if (!options.srcsetExtended && srcsetSupport) {
|
110 |
+
$el.attr('srcset', srcset);
|
111 |
+
$el.attr('data-srcset', '');
|
112 |
+
} else {
|
113 |
+
$el.lazyLoadXT.srcAttr = parseSrcset;
|
114 |
+
}
|
115 |
+
}
|
116 |
+
});
|
117 |
+
|
118 |
+
})(window.jQuery || window.Zepto || window.$, window, document);
|
assets/js/jquery.lazyloadxt.srcset.min.js
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/* Lazy Load XT 1.0.6 | MIT License */
|
2 |
+
!function(t,r,e,n){function s(r,e){return Math[e].apply(null,t.map(r,function(t){return t[o]}))}function a(t){return t[o]>=g[o]||t[o]===d}function c(t){return t[o]===d}function i(n){var i=n.attr(u.srcsetAttr);if(!i)return!1;var l=t.map(i.split(","),function(t){return{url:x.exec(t)[1],w:parseFloat((f.exec(t)||p)[1]),h:parseFloat((w.exec(t)||p)[1]),x:parseFloat((h.exec(t)||m)[1])}});if(!l.length)return!1;var A,v,E=e.documentElement;g={w:r.innerWidth||E.clientWidth,h:r.innerHeight||E.clientHeight,x:r.devicePixelRatio||1};for(A in g)o=A,d=s(l,"max"),l=t.grep(l,a);for(A in g)o=A,d=s(l,"min"),l=t.grep(l,c);return v=l[0].url,u.srcsetExtended&&(v=(n.attr(u.srcsetBaseAttr)||"")+v+(n.attr(u.srcsetExtAttr)||"")),v}var o,d,u=t.lazyLoadXT,l=function(){return"srcset"in new Image}(),x=/^\s*(\S*)/,f=/\S\s+(\d+)w/,w=/\S\s+(\d+)h/,h=/\S\s+([\d\.]+)x/,p=[0,1/0],m=[0,1],A={srcsetAttr:"data-srcset",srcsetExtended:!1,srcsetBaseAttr:"data-srcset-base",srcsetExtAttr:"data-srcset-ext"},g={w:0,h:0,x:0};for(o in A)u[o]===n&&(u[o]=A[o]);u.selector+=",img["+u.srcsetAttr+"]",t(e).on("lazyshow","img",function(t,r){var e=r.attr(u.srcsetAttr);e&&(!u.srcsetExtended&&l?(r.attr("srcset",e),r.attr("data-srcset","")):r.lazyLoadXT.srcAttr=i)})}(window.jQuery||window.Zepto||window.$,window,document);
|
classes/class-a3-lazy-load.php
CHANGED
@@ -125,7 +125,10 @@ class A3_Lazy_Load
|
|
125 |
|
126 |
do_action('before_a3_lazy_load_xt_style');
|
127 |
|
128 |
-
|
|
|
|
|
|
|
129 |
|
130 |
do_action('after_a3_lazy_load_xt_style');
|
131 |
|
@@ -137,9 +140,14 @@ class A3_Lazy_Load
|
|
137 |
}
|
138 |
|
139 |
do_action('before_a3_lazy_load_xt_script');
|
|
|
140 |
wp_deregister_script( 'jquery-lazyloadxt' );
|
141 |
-
|
142 |
-
|
|
|
|
|
|
|
|
|
143 |
do_action('after_a3_lazy_load_xt_script');
|
144 |
}
|
145 |
|
@@ -270,6 +278,11 @@ class A3_Lazy_Load
|
|
270 |
$attr['src'] = $A3_Lazy_Load->_placeholder_url;
|
271 |
$attr['class'] = 'lazy-hidden '. $attr['class'];
|
272 |
$attr['data-lazy-type'] = 'image';
|
|
|
|
|
|
|
|
|
|
|
273 |
|
274 |
return $attr;
|
275 |
}
|
@@ -302,6 +315,7 @@ class A3_Lazy_Load
|
|
302 |
// replace the src and add the data-src attribute
|
303 |
$replaceHTML = '';
|
304 |
$replaceHTML = preg_replace( '/<img(.*?)src=/is', '<img$1src="' . $this->_placeholder_url . '" data-lazy-type="image" data-src=', $imgHTML );
|
|
|
305 |
|
306 |
// add the lazy class to the img element
|
307 |
if ( preg_match( '/class=["\']/i', $replaceHTML ) ) {
|
@@ -328,7 +342,15 @@ class A3_Lazy_Load
|
|
328 |
return $content;
|
329 |
}
|
330 |
|
|
|
|
|
|
|
|
|
|
|
331 |
|
|
|
|
|
|
|
332 |
static function filter_videos( $content, $include_noscript = null ) {
|
333 |
if ( is_admin() ) {
|
334 |
return $content;
|
125 |
|
126 |
do_action('before_a3_lazy_load_xt_style');
|
127 |
|
128 |
+
wp_register_style( 'jquery-lazyloadxt-fadein-css', apply_filters( 'a3_lazy_load_effect_css', A3_LAZY_LOAD_CSS_URL.'/jquery.lazyloadxt.fadein.css' ), self::version );
|
129 |
+
wp_register_style( 'jquery-lazyloadxt-spinner-css', apply_filters( 'a3_lazy_load_effect_css', A3_LAZY_LOAD_CSS_URL.'/jquery.lazyloadxt.spinner.css' ), self::version );
|
130 |
+
|
131 |
+
wp_enqueue_style( 'jquery-lazyloadxt-'.$effect.'-css' );
|
132 |
|
133 |
do_action('after_a3_lazy_load_xt_style');
|
134 |
|
140 |
}
|
141 |
|
142 |
do_action('before_a3_lazy_load_xt_script');
|
143 |
+
|
144 |
wp_deregister_script( 'jquery-lazyloadxt' );
|
145 |
+
wp_register_script( 'jquery-lazyloadxt', apply_filters( 'a3_lazy_load_main_script', A3_LAZY_LOAD_JS_URL.'/jquery.lazyloadxt'.$suffix.'.js' ), array( 'jquery' ), self::version, $in_footer );
|
146 |
+
wp_register_script( 'jquery-lazyloadxt-srcset', apply_filters( 'a3_lazy_load_main_script', A3_LAZY_LOAD_JS_URL.'/jquery.lazyloadxt.srcset'.$suffix.'.js' ), array( 'jquery', 'jquery-lazyloadxt' ), self::version, $in_footer );
|
147 |
+
wp_register_script( 'jquery-lazyloadxt-extend', apply_filters( 'a3_lazy_load_extend_script', A3_LAZY_LOAD_JS_URL.'/jquery.lazyloadxt.extend.js' ), array( 'jquery', 'jquery-lazyloadxt', 'jquery-lazyloadxt-srcset' ), self::version, $in_footer );
|
148 |
+
|
149 |
+
wp_enqueue_script( 'jquery-lazyloadxt-extend' );
|
150 |
+
|
151 |
do_action('after_a3_lazy_load_xt_script');
|
152 |
}
|
153 |
|
278 |
$attr['src'] = $A3_Lazy_Load->_placeholder_url;
|
279 |
$attr['class'] = 'lazy-hidden '. $attr['class'];
|
280 |
$attr['data-lazy-type'] = 'image';
|
281 |
+
if ( isset( $attr['srcset'] ) ) {
|
282 |
+
$attr['data-srcset'] = $attr['srcset'];
|
283 |
+
$attr['srcset'] = '';
|
284 |
+
unset( $attr['srcset'] );
|
285 |
+
}
|
286 |
|
287 |
return $attr;
|
288 |
}
|
315 |
// replace the src and add the data-src attribute
|
316 |
$replaceHTML = '';
|
317 |
$replaceHTML = preg_replace( '/<img(.*?)src=/is', '<img$1src="' . $this->_placeholder_url . '" data-lazy-type="image" data-src=', $imgHTML );
|
318 |
+
$replaceHTML = preg_replace( '/<img(.*?)srcset=/is', '<img$1srcset="" data-srcset=', $replaceHTML );
|
319 |
|
320 |
// add the lazy class to the img element
|
321 |
if ( preg_match( '/class=["\']/i', $replaceHTML ) ) {
|
342 |
return $content;
|
343 |
}
|
344 |
|
345 |
+
function get_color( $type = 'background' ) {
|
346 |
+
$return = '';
|
347 |
+
if ( 'off' != $value ) {
|
348 |
+
|
349 |
+
}
|
350 |
|
351 |
+
return $return;
|
352 |
+
}
|
353 |
+
|
354 |
static function filter_videos( $content, $include_noscript = null ) {
|
355 |
if ( is_admin() ) {
|
356 |
return $content;
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Contributors: a3rev, A3 Revolution Software Development team, nguyencongtuan
|
|
4 |
Tags: a3 lazy load, Lazy Loading , image lazy load, lazyload
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 4.4
|
7 |
-
Stable tag: 1.5.
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -149,6 +149,12 @@ Automatic installation is the easiest option as WordPress handles the file trans
|
|
149 |
|
150 |
== Changelog ==
|
151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
= 1.5.1 - 2015/12/11 =
|
153 |
* Tweak - Change the placeholder image name from 'placeholder.gif' to 'lazy_placeholder.gif' to avoid conflict if thumb image has name like placehoder.gif
|
154 |
* Tweak - Change pattern parameter from "/data-src=['\"]/is" to "/ data-src=['\"]/is" to check 'data-src' exists as attribute of video, image, iframe, Solve the issue when 3rd party script adds attribute with format of name '***-data-src' to html tag.
|
@@ -245,6 +251,9 @@ Automatic installation is the easiest option as WordPress handles the file trans
|
|
245 |
|
246 |
== Upgrade Notice ==
|
247 |
|
|
|
|
|
|
|
248 |
= 1.5.1 =
|
249 |
Maintenance Update. 2 Tweaks and 1 bug fix for themes that use loop code, or where 3rd party scripts add name to property attributes
|
250 |
|
4 |
Tags: a3 lazy load, Lazy Loading , image lazy load, lazyload
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 4.4
|
7 |
+
Stable tag: 1.5.2
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
149 |
|
150 |
== Changelog ==
|
151 |
|
152 |
+
= 1.5.2 - 2015/12/24 =
|
153 |
+
* Tweak - Change on enqueue styles and scripts for faster load
|
154 |
+
* Tweak - Register new script 'jquery-lazyloadxt-srcset' for enqueue when lazyload script is called , full support for WP 4.4 Responsive Images
|
155 |
+
* Fix - Filter for change the 'srcset' attribute name to 'data-srcset' name to prevent browsers loading the image while page is loading
|
156 |
+
* Fix - Create a new script for when image comes into view port that it changes 'data-srcset' to 'srcset' so image is loaded then by lazy load
|
157 |
+
|
158 |
= 1.5.1 - 2015/12/11 =
|
159 |
* Tweak - Change the placeholder image name from 'placeholder.gif' to 'lazy_placeholder.gif' to avoid conflict if thumb image has name like placehoder.gif
|
160 |
* Tweak - Change pattern parameter from "/data-src=['\"]/is" to "/ data-src=['\"]/is" to check 'data-src' exists as attribute of video, image, iframe, Solve the issue when 3rd party script adds attribute with format of name '***-data-src' to html tag.
|
251 |
|
252 |
== Upgrade Notice ==
|
253 |
|
254 |
+
= 1.5.2 =
|
255 |
+
Maintenance Update. 2 code tweaks and 2 bug fixes to correct lazy load not showing WordPress v 4.4 Responsive Images in legacy and mobile browsers, should flush the cached if site have installed cache plugin
|
256 |
+
|
257 |
= 1.5.1 =
|
258 |
Maintenance Update. 2 Tweaks and 1 bug fix for themes that use loop code, or where 3rd party scripts add name to property attributes
|
259 |
|