WP懒惰加载插件自定义帖子类型
问题描述:
我使用wordpress懒惰加载插件https://wordpress.org/plugins/lazy-load/。它适用于帖子&页面,但自定义帖子类型不起作用,想知道如何将其应用于自定义帖子类型?感谢WP懒惰加载插件自定义帖子类型
add_filter('lazyload_images_placeholder_image', 'my_custom_lazyload_placeholder_image');
function my_custom_lazyload_placeholder_image($image) {
return 'images/preloader.gif';
}
这是我的尝试,但是不知道该怎么做:
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;
}
答
没关系我已经把我的CPT图像
$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, '');
我改为下方现在它工作。看起来像这个插件没有设置为支持上述获取发布缩略图图像的方法。
the_post_thumbnail('full', array('class' => 'img-responsive'));