WooCommerce: Disable Lightbox and Hyperlink on Product Images
-
Hello,
I would like to disable the lightbox/zoom and clickable hyperlink on the featured images for all products and their variations.
Presently, when users hover the curser over featured images, a zoomable lightbox appears; and, the image displays a clickable hyperlink that opens the image in a new window. I would like to disable both these features.
I have found and applied the following two lines of code, which work independently, but not concurrently. That is to say, I can disable either the lightbox/zoom feature OR the clickable hyperlink, but not both.
The code to disable the lightbox and product zoom is:
remove_theme_support( ‘wc-product-gallery-lightbox’ );
remove_theme_support( ‘wc-product-gallery-zoom’ );
The code to disable the image click is:
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 );Both lines of code have been applied to the Snippet plugin for custom CSS.
Any advice would be appreciated.
Thanks a million.
- The topic ‘WooCommerce: Disable Lightbox and Hyperlink on Product Images’ is closed to new replies.