a3rev / a3-lazy-load

Speed up your site and enhance frontend user's visual experience in PC's, Tablets and mobile with a3 Lazy Load.
GNU General Public License v3.0
18 stars 11 forks source link

Product thumbnails not lazy loaded on category page #26

Open alibasheer opened 5 years ago

alibasheer commented 5 years ago

Using:

Images in /shop/ or /category/category-name/ is not lazy loaded.

Note that:

alibasheer commented 5 years ago

The below commit on WooCommerce caused the issue: https://github.com/woocommerce/woocommerce/commit/6ed2ebb3ba97b84b7d39fa3ebd3e6c545fff18cc#diff-bad16647d10a7365519084a2fc793cbb

alibasheer commented 5 years ago

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 );
JapeNZ commented 4 years ago

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?