Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
quick wp plugin to get image lazy load with @tuupola's awesome plugin
- Loading branch information
0 parents
commit 06ef578
Showing
5 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|