diff --git a/js/gallery.js b/js/gallery.js index 294693a..18a9480 100644 --- a/js/gallery.js +++ b/js/gallery.js @@ -1,14 +1,17 @@ document.addEventListener('DOMContentLoaded', () => { const galleryContainer = document.getElementById('gallery-container'); + if (!galleryContainer) { + console.error("Gallery container not found!"); + return; + } - // Get filenames from HTML attribute const files = galleryContainer.dataset.files.split(','); files.forEach((file, index) => { const img = document.createElement('img'); img.src = `gallery/${file.trim()}`; img.alt = `Image ${index + 1}`; - img.onerror = () => { img.style.display = 'none'; }; // hide broken images + img.onerror = () => { img.style.display = 'none'; }; galleryContainer.appendChild(img); }); });