I need to modify the_post_thumbnail function to run “Lazyload” on it,
i think there is two solutions :
1- modify the args to be something like this
the_post_thumbnail('product', array('data-original'=>$src, 'src'=>'grey.gif'));
(((NOT WORKING!)))
2- get only the image url from the function … i’ve tried alot of snippets and nothing worked for me , like this one !
$thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "size" );
any ideas??
thanks
If you want to apply lazyload to each attachment image, you can just add your hoot to
wp_get_attachment_image_attributes
filter:Or if you can use second approach:
If you dont want to use a hook, in the loop you can do like this:
Add to your template’s
functions.php
:Personally i’m using my own lazyload plugin, unveil.