diff options
Diffstat (limited to 'assets/js/lightbox.js')
| -rw-r--r-- | assets/js/lightbox.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/assets/js/lightbox.js b/assets/js/lightbox.js new file mode 100644 index 0000000..81c3613 --- /dev/null +++ b/assets/js/lightbox.js @@ -0,0 +1,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); +})(); |
