Skip to content

Commit

Permalink
quick wp plugin to get image lazy load with @tuupola's awesome plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ayn committed May 19, 2009
0 parents commit 06ef578
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
Binary file added images/grey.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions javascripts/jquery.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions javascripts/jquery.lazyload.pack.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions jq_img_lazy_load.php
@@ -0,0 +1,36 @@
<?php

/*
Plugin Name: jQuery lazy load plugin
Plugin URI:
Version: v0.1
Author: <a href="http://blog.andrewng.com/">Andrew Ng</a>
Description:
*/

function jquery_lazy_load_headers() {
$plugin_path = plugins_url('/jq-lazy-load/');
$lazy_url = $plugin_path . 'javascripts/jquery.lazyload.pack.js';
$jq_url = $plugin_path . 'javascripts/jquery.js';
wp_deregister_script('jquery');
wp_enqueue_script('jquery', $jq_url, false, '1.3.2');
wp_enqueue_script('jquerylazyload', $lazy_url, 'jquery', '1.4.0');
}

function jquery_lazy_load_ready() {
$placeholdergif = plugins_url('/jq-lazy-load/images/grey.gif');
echo <<<EOF
<script type="text/javascript">
$(document).ready(function($){
$("img").lazyload({
effect:"fadeIn",
placeholder: "$placeholdergif"
});
});
</script>
EOF;
}

add_action('wp_head', 'jquery_lazy_load_headers', 5);
add_action('wp_head', 'jquery_lazy_load_ready', 12);
?>
17 changes: 17 additions & 0 deletions readme.txt
@@ -0,0 +1,17 @@
=== jQuery Image Lazy Load WP ===
Contributors: ayn
Tags: images, jquery, javascript, optimization
Requires at least: 2.0
Tested up to: 2.7.x
Stable tag: 2.7

add jquery lazy loading to images

== Description ==

add lazy loading to WP, more info at http://plugins.jquery.com/project/lazyload

== Installation ==

unzip archive to wp-content/plugins directory, and activate it in Plugins page in wp-admin

0 comments on commit 06ef578

Please sign in to comment.