Support » Fixing WordPress » How to disable the image opening as attachment

  • Hi. Does anyone know how can I disable the image opening as url attachment when the customer clicks on the photo of the product? I have researched online a lot and changed some settings and downloaded plugins but nothing seems to be working. I’m using ecommerce to list the products. It is very important for my website as we are selling the photos.

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Try adding this to your functions.php file:

    function remove_product_image_link( $html, $post_id ) {
    return preg_replace( “!<(a|/a).*?>!”, ”, $html );
    }
    add_filter( ‘woocommerce_single_product_image_thumbnail_html’, ‘remove_product_image_link’, 10, 2 );

    Thank you majaid. Unfortunately there were errors when i copied your functions so i google it and found this which worked:
    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 not have found it without your help

    I just noticed that they can still open it and copy if they right click on it. Any idea how to stop this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to disable the image opening as attachment’ is closed to new replies.