Skip to content

Commit be08f32

Browse files
committed
automatically add required css to the page
1 parent f897875 commit be08f32

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

jq_img_lazy_load.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,20 @@ class jQueryLazyLoad {
1313
var $do_footer = false;
1414

1515
function __construct() {
16+
add_action('wp_head', array($this, 'action_header'));
1617
add_action('wp_enqueue_scripts', array($this, 'action_enqueue_scripts'));
1718
add_filter('the_content', array($this, 'filter_the_content'));
1819
add_filter('wp_get_attachment_link', array($this, 'filter_the_content'));
19-
add_action('wp_footer', array($this, 'action_footer'), 15);
20+
add_action('wp_footer', array($this, 'action_footer'));
21+
}
22+
23+
function action_header() {
24+
echo <<<EOF
25+
<style type='text/css'>
26+
img.lazy { display: none; }
27+
</style>
28+
29+
EOF;
2030
}
2131

2232
function action_enqueue_scripts() {
@@ -64,6 +74,7 @@ function action_footer() {
6474
$("img.lazy").show().lazyload({effect: "fadeIn"});
6575
})(jQuery);
6676
</script>
77+
6778
EOF;
6879
}
6980
}

0 commit comments

Comments
 (0)