Version Description
- Adds noscript tags to allow the image to show up in no-js contexts (including crawlers), props smub
- Lazy Load post thumbnails, props ivancamilov
Download this release
Release Info
| Developer | batmoo |
| Plugin | |
| Version | 0.2 |
| Comparing to | |
| See all releases | |
Code changes from version 0.1 to 0.2
- lazy-load.php +5 -6
- readme.txt +6 -1
lazy-load.php
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
/**
|
| 3 |
* Plugin Name: Lazy Load
|
| 4 |
* Description: Lazy load images to improve page load times. Uses jQuery.sonar to only load an image when it's visible in the viewport.
|
| 5 |
-
* Version: 0.
|
| 6 |
*
|
| 7 |
* Code by the WordPress.com VIP team, TechCrunch 2011 Redesign team, and Jake Goldman (10up LLC).
|
| 8 |
* Uses jQuery.sonar by Dave Artz (AOL): http://www.artzstudio.com/files/jquery-boston-2010/jquery.sonar/
|
|
@@ -12,13 +12,12 @@
|
|
| 12 |
|
| 13 |
class LazyLoad_Images {
|
| 14 |
|
| 15 |
-
const version = '0.
|
| 16 |
-
|
| 17 |
-
var $base_url = '';
|
| 18 |
|
| 19 |
function __construct() {
|
| 20 |
add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts' ) );
|
| 21 |
add_filter( 'the_content', array( $this, 'add_image_placeholders' ) );
|
|
|
|
| 22 |
}
|
| 23 |
|
| 24 |
function add_scripts() {
|
|
@@ -32,10 +31,10 @@ class LazyLoad_Images {
|
|
| 32 |
return $content;
|
| 33 |
|
| 34 |
// In case you want to change the placeholder image
|
| 35 |
-
$
|
| 36 |
|
| 37 |
// This is a pretty simple regex, but it works
|
| 38 |
-
$content = preg_replace( '#<img([^>]+?)src
|
| 39 |
|
| 40 |
return $content;
|
| 41 |
}
|
| 2 |
/**
|
| 3 |
* Plugin Name: Lazy Load
|
| 4 |
* Description: Lazy load images to improve page load times. Uses jQuery.sonar to only load an image when it's visible in the viewport.
|
| 5 |
+
* Version: 0.2
|
| 6 |
*
|
| 7 |
* Code by the WordPress.com VIP team, TechCrunch 2011 Redesign team, and Jake Goldman (10up LLC).
|
| 8 |
* Uses jQuery.sonar by Dave Artz (AOL): http://www.artzstudio.com/files/jquery-boston-2010/jquery.sonar/
|
| 12 |
|
| 13 |
class LazyLoad_Images {
|
| 14 |
|
| 15 |
+
const version = '0.2';
|
|
|
|
|
|
|
| 16 |
|
| 17 |
function __construct() {
|
| 18 |
add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts' ) );
|
| 19 |
add_filter( 'the_content', array( $this, 'add_image_placeholders' ) );
|
| 20 |
+
add_filter( 'post_thumbnail_html', array( $this, 'add_image_placeholders' ) );
|
| 21 |
}
|
| 22 |
|
| 23 |
function add_scripts() {
|
| 31 |
return $content;
|
| 32 |
|
| 33 |
// In case you want to change the placeholder image
|
| 34 |
+
$placeholder_image = apply_filters( 'lazyload_images_placeholder_image', $this->get_url( 'images/1x1.trans.gif' ) );
|
| 35 |
|
| 36 |
// This is a pretty simple regex, but it works
|
| 37 |
+
$content = preg_replace( '#<img([^>]+?)src=[\'"]([^\'">]*)[\'"]([^>]*)>#', sprintf( '<img${1}src="%s" data-lazy-src="${2}"${3}><noscript><img${1}src="${2}"${3}></noscript>', $placeholder_image ), $content );
|
| 38 |
|
| 39 |
return $content;
|
| 40 |
}
|
readme.txt
CHANGED
|
@@ -3,7 +3,7 @@ Contributors: batmoo, automattic, jakemgold, get10up
|
|
| 3 |
Tags: lazy load, images, front-end optimization
|
| 4 |
Requires at least: 3.2
|
| 5 |
Tested up to: 3.3
|
| 6 |
-
Stable tag: 0.
|
| 7 |
|
| 8 |
Lazy load images to improve page load times and server bandwidth. Images are loaded only when visible to the user.
|
| 9 |
|
|
@@ -27,6 +27,11 @@ No applicable screenshots
|
|
| 27 |
|
| 28 |
== Changelog ==
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
= 0.1 =
|
| 31 |
|
| 32 |
* Initial working version
|
| 3 |
Tags: lazy load, images, front-end optimization
|
| 4 |
Requires at least: 3.2
|
| 5 |
Tested up to: 3.3
|
| 6 |
+
Stable tag: 0.2
|
| 7 |
|
| 8 |
Lazy load images to improve page load times and server bandwidth. Images are loaded only when visible to the user.
|
| 9 |
|
| 27 |
|
| 28 |
== Changelog ==
|
| 29 |
|
| 30 |
+
= 0.2 =
|
| 31 |
+
|
| 32 |
+
* Adds noscript tags to allow the image to show up in no-js contexts (including crawlers), props smub
|
| 33 |
+
* Lazy Load post thumbnails, props ivancamilov
|
| 34 |
+
|
| 35 |
= 0.1 =
|
| 36 |
|
| 37 |
* Initial working version
|
