Imagery

Imagery

Holly18
Excursionist
20 0 3

Hi there,

Could someone please help me. Currently, customers have to click on a little button on the top left hand side of my product image for it to open. Is there a way I can make it open if they click on anywhere in the image? URL: https://salourlingerie.com/products/rochelle-bodysuit

My theme is drop.

Thanks!

Replies 2 (2)

lynth
Shopify Partner
107 5 14

Hi, yes. I think the simplest way is to add a custom JS snippet in some JS or the liquid file (theme.liquid).

 

<script>
document.querySelectorAll(".product__image").forEach((img) => {
  img.addEventListener("click", () => {
    document.querySelector(".js-zoom-btn").click();
  });
});
</script>

 

If my tips are useful, just mark it as the solution. Cheers!
Feeling grateful? Buy me a coffee!

BSSCommerce-B2B
Shopify Partner
1752 535 594

@Holly18,

Step 1: Go to Admin -> Online store -> Theme > Edit code

Step 2: Search for the file theme.liquid

Step 3: Add this code before </body> tag

<script>
document.addEventListener("DOMContentLoaded", (event) => {
  const productGalleryContainers = document.querySelectorAll('.product-gallery__media-container');
if (productGalleryContainers.length) {
    productGalleryContainers.forEach((productGalleryContainer) => {
        const productImg = productGalleryContainer.querySelector('.product__image');
        productImg.addEventListener('click', () => {
            productGalleryContainer.querySelector('a.js-zoom-btn.product-gallery__zoom-btn').click();
        });
    });
}
});
</script>

B2B Wholesale Solution: Streamline your B2B operation with advanced features like wholesale registration forms, custom pricing.


B2B Portal, Quote, Net 30: Speed up purchasing and streamline your quotation process with advanced features like quick order, request for quote.


B2B Lock Password Protect: Easily control access to pages, products, and pricing with robust features.


BSS Commerce - Full-service eCommerce Agency I Use Shopify for 1$ in the first month now