lightgallery.js 1.x is not actively maintained . Please upgrade to version 2

Gallery With Dynamic Mode.

LightGallery can be instantiated and launched programmatically by setting dynamic option to true and populating dynamicEl option by passing array of objects representing the gallery elements. more info.

Javascript

document.getElementById('dynamic').addEventListener('click', function() {
    lightGallery(document.getElementById('dynamic'), {
        dynamic: true,
        dynamicEl: [{
            "src": '../static/img/1.jpg',
            'thumb': '../static/img/thumb-1.jpg',
            'subHtml': '<h4>Fading Light</h4><p>Classic view from Rigwood Jetty on Coniston Water an old archive shot similar to an old post but a little later on.</p>'
        }, {
            'src': '../static/img/2.jpg',
            'thumb': '../static/img/thumb-2.jpg',
            'subHtml': "<h4>Bowness Bay</h4><p>A beautiful Sunrise this morning taken En-route to Keswick not one as planned but I'm extremely happy I was passing the right place at the right time....</p>"
        }, {
            'src': '../static/img/3.jpg',
            'thumb': '../static/img/thumb-3.jpg',
            'subHtml': "<h4>Coniston Calmness</h4><p>Beautiful morning</p>"
        }]
    })

});