a3-lazy-load
a3-lazy-load copied to clipboard
Product thumbnails not lazy loaded on category page
Using:
- WooCommerce 5.0+
- a3 Lazy Load: 1.9.1
- WordPress: 4.9.8
- Theme Twenty Seventeen: 1.7
Images in /shop/
or /category/category-name/
is not lazy loaded.
Note that:
- Lazy load CSS and JS files are included in the pages
-
.lazy-hidden
is not added to the images
The below commit on WooCommerce caused the issue: https://github.com/woocommerce/woocommerce/commit/6ed2ebb3ba97b84b7d39fa3ebd3e6c545fff18cc#diff-bad16647d10a7365519084a2fc793cbb
A fix:
function lebelik_woocommerce_product_get_image( $image, $this_product, $size, $attr ){
if ( $this_product->get_image_id() ) {
$image = get_the_post_thumbnail( $this_product->get_id(), $size, $attr );
}
return $image;
}
add_filter( 'woocommerce_product_get_image', 'lebelik_woocommerce_product_get_image', 10, 4 );
Hi @alibasheer, Thank you so much for this! Can confirm the fix works and is still required.
@a3rev Any plans to include in an update?