1
I need to get the data-src
of the gallery’s open item, as the user advances the photos in the gallery, an input should be updated.
<div class="item " data-src="assets/img/tour/-11521134609.jpg" data-sub-html="" style="position: absolute; left: 0px; top: 0px;">
<img alt="" src="assets/img/tour/-11521134609.jpg"><br>
</div>
<div class="item " data-src="assets/img/tour/-445452345.jpg" data-sub-html="" style="position: absolute; left: 0px; top: 0px;">
<img alt="" src="assets/img/tour/-445452345.jpg"><br>
</div>
<div class="item " data-src="assets/img/tour/-asdfasdfasdf.jpg" data-sub-html="" style="position: absolute; left: 0px; top: 0px;">
<img alt="" src="assets/img/tour/-asdfasdfasdf.jpg"><br>
</div>
$(document).ready(function(){
var $lg = $('#captions').lightGallery({
mode: 'lg-fade',
width: '800px',
height: '700px',
addClass: 'fixed-size',
counter: false,
startClass: '',
enableSwipe: false,
enableDrag: false,
speed: 500,
closable:true,
download: false,
share: false,
thumbnail:false,
autoplay: false,
actualSize: false,
fullScreen: false,
zoom:false
});
$lg.on('onAfterSlide.lg', function (event ) {
console.log( $lg.data('lightGallery').$items.eq(0).data('src') );
});
});
The return on the console is always being assets/img/tour/-11521134609.jpg
which is the name of the first image.