Skip to content

Commit 06ef578

Browse files
committed
quick wp plugin to get image lazy load with @tuupola's awesome plugin
0 parents  commit 06ef578

File tree

5 files changed

+73
-0
lines changed

5 files changed

+73
-0
lines changed

images/grey.gif

43 Bytes
Loading

javascripts/jquery.js

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

javascripts/jquery.lazyload.pack.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jq_img_lazy_load.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
/*
4+
Plugin Name: jQuery lazy load plugin
5+
Plugin URI:
6+
Version: v0.1
7+
Author: <a href="http://blog.andrewng.com/">Andrew Ng</a>
8+
Description:
9+
*/
10+
11+
function jquery_lazy_load_headers() {
12+
$plugin_path = plugins_url('/jq-lazy-load/');
13+
$lazy_url = $plugin_path . 'javascripts/jquery.lazyload.pack.js';
14+
$jq_url = $plugin_path . 'javascripts/jquery.js';
15+
wp_deregister_script('jquery');
16+
wp_enqueue_script('jquery', $jq_url, false, '1.3.2');
17+
wp_enqueue_script('jquerylazyload', $lazy_url, 'jquery', '1.4.0');
18+
}
19+
20+
function jquery_lazy_load_ready() {
21+
$placeholdergif = plugins_url('/jq-lazy-load/images/grey.gif');
22+
echo <<<EOF
23+
<script type="text/javascript">
24+
$(document).ready(function($){
25+
$("img").lazyload({
26+
effect:"fadeIn",
27+
placeholder: "$placeholdergif"
28+
});
29+
});
30+
</script>
31+
EOF;
32+
}
33+
34+
add_action('wp_head', 'jquery_lazy_load_headers', 5);
35+
add_action('wp_head', 'jquery_lazy_load_ready', 12);
36+
?>

readme.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
=== jQuery Image Lazy Load WP ===
2+
Contributors: ayn
3+
Tags: images, jquery, javascript, optimization
4+
Requires at least: 2.0
5+
Tested up to: 2.7.x
6+
Stable tag: 2.7
7+
8+
add jquery lazy loading to images
9+
10+
== Description ==
11+
12+
add lazy loading to WP, more info at http://plugins.jquery.com/project/lazyload
13+
14+
== Installation ==
15+
16+
unzip archive to wp-content/plugins directory, and activate it in Plugins page in wp-admin
17+

0 commit comments

Comments
 (0)