lightGallery icon indicating copy to clipboard operation
lightGallery copied to clipboard

lightgallery doesn't work

Open nestle49 opened this issue 1 year ago • 1 comments

Description

lightgallery doesn't work

Steps to reproduce

  1. Download repo
  2. include functions.php of wordpress
wp_enqueue_style( 'lightgallery-css', get_template_directory_uri() . '/assets/lightgallery/css/lightgallery.css', array(), _S_VERSION, true );
		wp_enqueue_script( 'lightgallery-js', get_template_directory_uri() . '/assets/lightgallery/lightgallery.min.js', array(), _S_VERSION, true );
		wp_enqueue_script( 'lightgallery-thumbnail-js', get_template_directory_uri() . '/assets/lightgallery/plugins/thumbnail/lg-thumbnail.min.js', array(), _S_VERSION, true );
		wp_enqueue_script( 'lightgallery-zoom-js', get_template_directory_uri() . '/assets/lightgallery/plugins/zoom/lg-zoom.min.js', array(), _S_VERSION, true );
  1. add id and data-src links
  2. include js

JS code that you use to initialize lightGallery.

document.addEventListener('DOMContentLoaded', () => {
    lightGallery(document.getElementById('gallery'), {
        plugins: [lgZoom, lgThumbnail],
        speed: 500,
    });

    const showMoreButton = document.querySelector('.gallery__show-more')
    showMoreButton?.addEventListener('click', () => {
        console.log('clc')
        // lightbox.open()
    })
})

Sample HTML markup

<div id="gallery" class="photos__images h-100 d-grid flex-1 gap-24 position-relative overflow-hidden">
                            {% for item in gallery[1:6] %}
                                <a class="overflow-hidden photos__item"
                                   data-src="{{- item.src -}}"
                                >
                                    <picture class="d-flex">
                                        <source srcset="{{- item.src|towebp(100) -}}" type="image/webp">
                                        <img src="{{- item.src -}}"
                                             alt="{{ item.alt }}"
                                             class="br-14 overflow-hidden object-fit-cover"
                                             loading="lazy"
                                        />
                                    </picture>
                                </a>
                            {% endfor %}
                        </div>

Environment

  • Browser and version -
  • OS -
  • lightGallery version -

Additional context

nestle49 avatar Jun 14 '24 00:06 nestle49

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 14 '24 03:08 stale[bot]