organisation & minor fixes

This commit is contained in:
2025-12-03 17:24:24 +01:00
parent 2cad7ff6ea
commit 8e20743e8b
30 changed files with 158 additions and 497 deletions

View File

@@ -141,7 +141,7 @@ async function toggleFavorite(item) {
}
}
function createGalleryCard(item) {
function createGalleryCard(item, isLoadMore = false) {
const card = document.createElement('a');
card.className = 'gallery-card grid-item';
card.href = `/gallery/${item.provider || currentProvider || 'unknown'}/${encodeURIComponent(item.id)}`;
@@ -151,9 +151,10 @@ function createGalleryCard(item) {
img.className = 'gallery-card-img';
img.src = getProxiedImageUrl(item);
img.alt = getTagsArray(item).join(', ') || 'Image';
img.loading = 'lazy';
if (isLoadMore) {
img.loading = 'lazy';
}
const favBtn = document.createElement('button');
favBtn.className = 'fav-btn';
@@ -273,7 +274,7 @@ async function searchGallery(isLoadMore = false) {
if (msnry) msnry.remove(toRemove);
toRemove.forEach(el => el.remove());
const newCards = results.map(item => createGalleryCard(item));
const newCards = results.map((item, index) => createGalleryCard(item, isLoadMore));
newCards.forEach(card => resultsContainer.appendChild(card));
if (msnry) msnry.appended(newCards);