Enable lightbox gallery for a single woocommerce images

Viewed 389

I disabled product image zoom on hover. Lightbox gallery opens after click the magnifying glass icon. I would like to get the same effect after clicking on the product photo. Currently, after clicking on the photo, a lightbox opens, but only a single photo (I cannot navigate to other photos in the gallery).

Gallery opens after clicking on

<a href="#" class="woocommerce-product-gallery__trigger"></a>

I found something in single-product.js file:

/**
     * Init PhotoSwipe.
     */
    ProductGallery.prototype.initPhotoswipe = function() {
        if ( this.zoom_enabled && this.$images.length > 0 ) {
            this.$target.prepend( '<a href="#" class="woocommerce-product-gallery__trigger"></a>' );
            this.$target.on( 'click', '.woocommerce-product-gallery__trigger', this.openPhotoswipe );
            this.$target.on( 'click', '.woocommerce-product-gallery__image a', function( e ) {
                e.preventDefault();
            });

            // If flexslider is disabled, gallery images also need to trigger photoswipe on click.
            if ( ! this.flexslider_enabled ) {
                this.$target.on( 'click', '.woocommerce-product-gallery__image a', this.openPhotoswipe );
            }
        } else {
            this.$target.on( 'click', '.woocommerce-product-gallery__image a', this.openPhotoswipe );
        }
    };

Is it possible to set the lightbox gallery trigger on the entire picture and not just a magnifying button?

0 Answers
Related