sachinchoolur / lightGallery

A customizable, modular, responsive, lightbox gallery plugin.

Home Page:https://www.lightgalleryjs.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot use plugins

David-COUDRAY opened this issue · comments

Hi there,

I tried to load lgZoom and lgThumbnail plugins with lightGallery:
lightGallery:- make sure lightGallery module is properly initiated.

Only Fullscreen works fine.

I use WordPress 5.9 (last version) and I push all scripts with wp_enqueue_scripts hook.

wp_enqueue_style( 'lg_bundle_style', get_stylesheet_directory_uri() . '/vendor/lightGallery/dist/css/lightgallery-bundle.min.css', array(), VERSION );
wp_enqueue_script( 'lg_script', get_stylesheet_directory_uri() . '/vendor/lightGallery/dist/lightgallery.min.js', array(), VERSION, true);
wp_enqueue_script( 'lg_zoom_script', get_stylesheet_directory_uri() . '/vendor/lightGallery/dist/plugins/zoom/lg-zoom.min.js', array(), VERSION, true);
wp_enqueue_script( 'lg_thumbnail_script', get_stylesheet_directory_uri() . '/vendor/lightGallery/dist/plugins/thumbnail/lg-thumbnail.min.js', array(), VERSION, true);
wp_enqueue_script( 'lg_fullscreen_script', get_stylesheet_directory_uri() . '/vendor/lightGallery/dist/plugins/fullscreen/lg-fullscreen.min.js', array(), VERSION, true);
lightGallery($('.woocommerce-product-gallery__wrapper'), {
            selector: document.querySelectorAll('.wc_gallery_image_link'),
            plugins: [lgFullscreen, lgZoom, lgThumbnail],
        });

Exemple here : https://poc.aprocom.fr/produit/masse-beton/test-variant/

Tried with 2.5.0 and 2.4.0 versions

Hey David,
Looks like you are passing a jQuery element to lightGallery.

Could you please try the following code?

lightGallery($('.woocommerce-product-gallery__wrapper')[0], {
            selector: '.wc_gallery_image_link',
            plugins: [lgFullscreen, lgZoom, lgThumbnail],
        });

Wow, works fine.
I'm sorry for this error and thanks for your quick help ;-)