BJ Lazy Load - Version 0.7.3

Version Description

Download this release

Release Info

Developer bjornjohansen
Plugin Icon 128x128 BJ Lazy Load
Version 0.7.3
Comparing to
See all releases

Code changes from version 0.7.2 to 0.7.3

Files changed (2) hide show
  1. bj-lazy-load.php +7 -7
  2. readme.txt +12 -9
bj-lazy-load.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: BJ Lazy Load
4
  Plugin URI: http://wordpress.org/extend/plugins/bj-lazy-load/
5
  Description: Lazy image loading makes your site load faster and saves bandwidth.
6
- Version: 0.7.2
7
  Author: Bjørn Johansen
8
  Author URI: http://twitter.com/bjornjohansen
9
  Text Domain: bj-lazy-load
@@ -33,7 +33,7 @@ require_once( dirname(__FILE__) . '/inc/class-bjll-skip-post.php' );
33
  if ( ! class_exists( 'BJLL' ) ) {
34
  class BJLL {
35
 
36
- const version = '0.7.2';
37
  protected $_placeholder_url;
38
  protected $_skip_classes;
39
 
@@ -169,14 +169,14 @@ if ( ! class_exists( 'BJLL' ) ) {
169
  protected function _filter_images( $content ) {
170
 
171
  $matches = array();
172
- preg_match_all( '/<img\s+.*?>/', $content, $matches );
173
 
174
  $search = array();
175
  $replace = array();
176
 
177
  if ( is_array( $this->_skip_classes ) ) {
178
  $skip_images_preg_quoted = array_map( 'preg_quote', $this->_skip_classes );
179
- $skip_images_regex = sprintf( '/class=".*(%s).*"/', implode( '|', $skip_images_preg_quoted ) );
180
  }
181
 
182
  foreach ( $matches[0] as $imgHTML ) {
@@ -184,13 +184,13 @@ if ( ! class_exists( 'BJLL' ) ) {
184
  // don't to the replacement if a skip class is provided and the image has the class
185
  if ( ! ( is_array( $this->_skip_classes ) && preg_match( $skip_images_regex, $imgHTML ) ) ) {
186
  // replace the src and add the data-src attribute
187
- $replaceHTML = preg_replace( '/<img(.*?)src=/i', '<img$1src="' . $this->_placeholder_url . '" data-lazy-type="image" data-lazy-src=', $imgHTML );
188
 
189
  // add the lazy class to the img element
190
  if ( preg_match( '/class=["\']/i', $replaceHTML ) ) {
191
- $replaceHTML = preg_replace( '/class=(["\'])(.*?)["\']/i', 'class=$1lazy lazy-hidden $2$1', $replaceHTML );
192
  } else {
193
- $replaceHTML = preg_replace( '/<img/i', '<img class="lazy lazy-hidden"', $replaceHTML );
194
  }
195
 
196
  $replaceHTML .= '<noscript>' . $imgHTML . '</noscript>';
3
  Plugin Name: BJ Lazy Load
4
  Plugin URI: http://wordpress.org/extend/plugins/bj-lazy-load/
5
  Description: Lazy image loading makes your site load faster and saves bandwidth.
6
+ Version: 0.7.3
7
  Author: Bjørn Johansen
8
  Author URI: http://twitter.com/bjornjohansen
9
  Text Domain: bj-lazy-load
33
  if ( ! class_exists( 'BJLL' ) ) {
34
  class BJLL {
35
 
36
+ const version = '0.7.3';
37
  protected $_placeholder_url;
38
  protected $_skip_classes;
39
 
169
  protected function _filter_images( $content ) {
170
 
171
  $matches = array();
172
+ preg_match_all( '/<img[\s\r\n]+.*?>/is', $content, $matches );
173
 
174
  $search = array();
175
  $replace = array();
176
 
177
  if ( is_array( $this->_skip_classes ) ) {
178
  $skip_images_preg_quoted = array_map( 'preg_quote', $this->_skip_classes );
179
+ $skip_images_regex = sprintf( '/class=".*(%s).*"/s', implode( '|', $skip_images_preg_quoted ) );
180
  }
181
 
182
  foreach ( $matches[0] as $imgHTML ) {
184
  // don't to the replacement if a skip class is provided and the image has the class
185
  if ( ! ( is_array( $this->_skip_classes ) && preg_match( $skip_images_regex, $imgHTML ) ) ) {
186
  // replace the src and add the data-src attribute
187
+ $replaceHTML = preg_replace( '/<img(.*?)src=/is', '<img$1src="' . $this->_placeholder_url . '" data-lazy-type="image" data-lazy-src=', $imgHTML );
188
 
189
  // add the lazy class to the img element
190
  if ( preg_match( '/class=["\']/i', $replaceHTML ) ) {
191
+ $replaceHTML = preg_replace( '/class=(["\'])(.*?)["\']/is', 'class=$1lazy lazy-hidden $2$1', $replaceHTML );
192
  } else {
193
+ $replaceHTML = preg_replace( '/<img/is', '<img class="lazy lazy-hidden"', $replaceHTML );
194
  }
195
 
196
  $replaceHTML .= '<noscript>' . $imgHTML . '</noscript>';
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: bjornjohansen
3
  Donate link: http://www.kiva.org/
4
  Tags: images, iframes, lazy loading, jquery, javascript, optimize, performance, bandwidth, responsive design, hidpi, retina
5
  Author URI: http://twitter.com/bjornjohansen
6
- Requires at least: 3.5
7
- Tested up to: 3.9.1
8
- Stable tag: 0.7.2
9
 
10
  Lazy loading makes your site load faster and saves bandwidth. Uses jQuery and degrades gracefully for non-js users. Works with both images and iframes.
11
 
@@ -61,9 +61,12 @@ Probably, your theme does not call wp_footer(). Edit the plugin settings to load
61
  Check your HTML source or see the magic at work in Web Inspector, FireBug or similar.
62
 
63
  == Changelog ==
64
-
65
- = Version 0.7.2 =
66
- Re-minified the combined js file for better compability with faulty minifiers
 
 
 
67
 
68
  = Version 0.7.1 =
69
  * Proper encoding of non-ASCII characters in filenames when using responsive or hiDPI images (thanks @testsiteoop)
@@ -188,9 +191,9 @@ Re-minified the combined js file for better compability with faulty minifiers
188
  * Released 2011-12-05
189
  * It works (or at least it does for me)
190
 
191
- == Upgrade Notice ==
192
-
193
- = 0.7.2 =
194
  Improved minification compability
195
 
196
  = 0.6.10 =
3
  Donate link: http://www.kiva.org/
4
  Tags: images, iframes, lazy loading, jquery, javascript, optimize, performance, bandwidth, responsive design, hidpi, retina
5
  Author URI: http://twitter.com/bjornjohansen
6
+ Requires at least: 3.5
7
+ Tested up to: 4.0
8
+ Stable tag: 0.7.3
9
 
10
  Lazy loading makes your site load faster and saves bandwidth. Uses jQuery and degrades gracefully for non-js users. Works with both images and iframes.
11
 
61
  Check your HTML source or see the magic at work in Web Inspector, FireBug or similar.
62
 
63
  == Changelog ==
64
+
65
+ = Version 0.7.3 =
66
+ * Works with newlines in the HTML string for the IMG element
67
+
68
+ = Version 0.7.2 =
69
+ * Re-minified the combined js file for better compability with faulty minifiers
70
 
71
  = Version 0.7.1 =
72
  * Proper encoding of non-ASCII characters in filenames when using responsive or hiDPI images (thanks @testsiteoop)
191
  * Released 2011-12-05
192
  * It works (or at least it does for me)
193
 
194
+ == Upgrade Notice ==
195
+
196
+ = 0.7.2 =
197
  Improved minification compability
198
 
199
  = 0.6.10 =