blob: 81c3613e4946924ed25837bf10b1ca87a1b6755c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
/**
* lightbox.js
* Photo lightbox initialization
*/
(function() {
'use strict';
if (typeof PhotoUtils === 'undefined') return;
const photoGrid = document.querySelector('.photo-grid[data-lightbox="true"]');
if (!photoGrid) return;
const photoCards = photoGrid.querySelectorAll('.photo-card');
const photosData = [];
photoCards.forEach((card, index) => {
const figure = card.querySelector('figure');
const img = card.querySelector('img');
photosData.push({
index,
src: figure.getAttribute('data-src') || img.src,
alt: figure.getAttribute('data-alt') || img.alt,
caption: figure.getAttribute('data-caption'),
location: figure.getAttribute('data-location'),
});
});
// Initialize lightbox with PhotoUtils
PhotoUtils.initLightbox('.photo-grid', photosData);
})();
|