Support » Plugin: WooCommerce » How to disable ‘click’ on product page image?

  • Resolved Gemini23

    (@gemini23)


    Can anyone advise how to prevent the clickable link from happening on PRODUCT PAGES – but NOT on the Category pages.

    ie I don’t want the image to be clickable an open to a fullscreen image on each product page.

    Many thanks.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support maykato

    (@maykato)

    Hello,

    I found another article about this topic here. You can use the code below to make the image unclickable:

    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 );

    I would recommend using a plugin like Code Snippets to add the code to your site.

    Thread Starter Gemini23

    (@gemini23)

    Thanks Maykato – that didn’t work.

    Plugin Support kellymetal a11n

    (@kellymetal)

    Hi there @gemini23,

    I tried using the snippet provided by @maykato, and it seemed to work well on my site. It’s possible your theme is handling things differently and changing the default behavior.

    Taking a look at your product page, I see the image is still clickable. You could try instead using CSS to disable the click on the image like this:

    
    .woocommerce-product-gallery__image {
      pointer-events: none;
    }
    

    You can add that to the “Additional CSS” section of your Customizer (Appearance > Customize).

    Thread Starter Gemini23

    (@gemini23)

    @kellymetal

    HURRAY! That has worked 🙂

    Many thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to disable ‘click’ on product page image?’ is closed to new replies.