Automattic / lazy-load

Lazy load images on your WordPress site to improve page load times and server bandwidth.

Home Page:https://wordpress.org/plugins/lazy-load/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom Post Type Issue

rowboat85 opened this issue · comments

Hi there I am having an issue with showing the lazy load to custom post type. It works for posts and pages - how can I get to work for custom post type?

My poor attempt is below:

Thanks, you help is appreciated.

add_filter( 'lazyload_images_placeholder_image', 'my_custom_lazyload_placeholder_image' ); function my_custom_lazyload_placeholder_image( $image_src, $image ) { $image_src = 'images/preloader.gif'; return $image_src; $post_types = $post_types = array( 'post', 'video_library', 'example1_posts', 'example2_posts', 'example3_posts', 'example4_posts', 'example5_posts', 'example6_posts'); $image->set( 'post_type', $post_types ); return $image; }

Never mind I had set my CPT images to
$attachment = wp_get_attachment(get_post_thumbnail_id($post->ID)); $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 650,350 ), false, '');
I changed to
the_post_thumbnail('full', array( 'class' => 'img-responsive' ) );