Skip to content

Instantly share code, notes, and snippets.

@menslow
menslow / lazyload-get-the-post-thumbnail.php
Last active November 13, 2017 13:10
Rewrite of the WordPress "get_the_post_thumbnail" for compatibility with jQuery LazyLoad plugin
<php
// Rewrite of "get_the_post_thumbnail" for compatibility with jQuery LazyLoad plugin
function my_get_the_post_lazyload_thumbnail( $post_id = false, $size = 'full' ) {
if ( $post_id ) {
// Get the id of the attachment
$attachment_id = get_post_thumbnail_id( $post_id );
if ( $attachment_id ) {
$src = wp_get_attachment_image_src( $attachment_id, $size );
if ($src) {
$img = get_the_post_thumbnail( $post_id, $size, array(