I have integrated the lightgallery plugin into my website from
Currently, I am struggling to retrieve the data-src value when an image is clicked.
The basic HTML structure is as shown below:
<div id="work-grid" class="grid wow fadeIn animated">
<div class="ecp-thumbnail element-item landing" data-iframe="true" data-src="image/landingpages/alta_1.jpg">
<img class="img-responsive img-thumbnail" src="image/landingpages/thumb_alta_1.jpg" />
</div>
</div>
Here is the relevant JavaScript code:
var $workGrid = $("#work-grid");
$workGrid.lightGallery({
mode: 'lg-fade',
cssEasing: 'cubic-bezier(0.25, 0, 0.25, 1)',
download: false,
share: false,
selector: 'this'
});
$workGrid.on('onBeforeOpen.lg', function (event, prevIndex, index) {
alert($workGrid.data('src'));
});
Despite adding selector: 'this', I am unable to extract the data-src attribute value of the selected image. Can someone guide me on how to properly utilize this functionality?
I would greatly appreciate any assistance provided.