Site logo

Archived topic

Open product image in a new tab

5 replies · Started by Zuzana on October 11, 2018

Viewing posts 1–6 of 6

Hello!

I am searching for a code which will help me to do the following for the Woocommerce single product image:
- remove the default zoom and lightbox from the picture
- open the whole image in a new tab instead, when the user clicks on the image

(The reason behind this is that the image actually represents text and with the default zoom option in the lightbox, the picture became too huge to be comfortable to read and moreover the only way to move down the image while in zoom was using drag and drop option, scrolling didn't work. So please, if there is another way how to solve this, I will be more than happy.)

I already tried to read some topics such as https://wordpress.org/support/topic/disable-lightbox-for-woocommerce-products/ but it didn´t really solve my problem.

You can check the website here: https://interweld.sk/produkty/zvaracie-elektrody/zvaracie-elektrody-nizko-a-stredne-legovane/iw-e-210/

I am really thankful for any help and for your time!

Zuzana

Hi there,

Try this PHP snippet:

add_action( 'wp', 'tu_remove_wc_zoom', 20 );
function tu_remove_wc_zoom() {
    remove_theme_support( 'wc-product-gallery-zoom' );
    remove_theme_support( 'wc-product-gallery-lightbox' );
}

Adding PHP: https://docs.generatepress.com/article/adding-php/

It should solve both problems.

Let me know :)

Hello Leo,

I placed the code to the website using Code Snippets plugin, but it didn't solve the problem. When the user clicks on the image, lightbox still appears. I would need that after clicking on the image, the image will be opened as regular URL in the new tab of the browser.

Thank you very much!
Zuzana

I've edited the code to remove lightbox as well.

Let me know :)

Now the lightbox disappeared, that is good. But is it possible that the picture is now opening in the new tab of the browser and not in the same one?

You'd have to ask WooCommerce for that part unfortuantely.

It will likely require modifying their existing structure.

This archived topic is closed to new replies.