From 12d114be9f31a619a2d2c6c515aa72ee38b3a09a Mon Sep 17 00:00:00 2001 From: esefxdz Date: Fri, 3 Oct 2025 11:54:01 +0300 Subject: [PATCH] test3 --- js/gallery.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/js/gallery.js b/js/gallery.js index fc23ce5..7103f0c 100644 --- a/js/gallery.js +++ b/js/gallery.js @@ -4,9 +4,24 @@ document.addEventListener('DOMContentLoaded', () => { for (let i = 1; i <= totalImages; i++) { const img = document.createElement('img'); - img.src = `gallery/${i}.jpg`; // assuming .jpg extension, change if needed img.alt = `Image ${i}`; - img.onerror = () => { img.style.display = 'none'; }; // hide broken images + + // Try jpg first + img.src = `gallery/${i}.jpg`; + + // fallback to png + img.onerror = () => { + img.src = `gallery/${i}.png`; + + // fallback to gif + img.onerror = () => { + img.src = `gallery/${i}.gif`; + + // hide if all fail + img.onerror = () => { img.style.display = 'none'; }; + }; + }; + galleryContainer.appendChild(img); } });