Removing the html image link from WooCommerce single product



Try this ... add the below code snippet in your functions.php file and let me know if it works or not ...

function custom_codefactry_single_product_image_html( $html, $post_id ) {
    return get_the_post_thumbnail( $post_id, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ) );
}
add_filter('woocommerce_single_product_image_html', 'custom_codefactry_single_product_image_html', 10, 2);

Hey

I tested the above code on a local dev site and an online test site and it has no effect.

The following CSS works in hiding the mouse pointer making the single product featured image not clickable.

.woocommerce div.product div.images .woocommerce-product-gallery__wrapper {
    pointer-events: none;
}

I know this question has been sitting for over a year, but I had the same issue. I found that this code worked for me:

function e12_remove_product_image_link( $html, $post_id ) {
    return preg_replace( "!<(a|/a).*?>!", '', $html );
}
add_filter( 'woocommerce_single_product_image_thumbnail_html', 'e12_remove_product_image_link', 10, 2 );


Write a reply

Login or register to write a reply, it's free!