Perf: Wiki Breed-Fotos nutzen _preview.webp + breeds/ in generate-previews (SW by-v938)

This commit is contained in:
rene 2026-05-14 12:42:20 +02:00
parent e397b9dff5
commit 3f0e09e5d2
5 changed files with 13 additions and 6 deletions

View file

@ -384,8 +384,13 @@ window.Page_wiki = (() => {
function _breedCardHtml(r) {
const fotoUrl = r.foto_url || r.user_foto || '';
// Für lokale Bilder: _preview.webp zuerst, bei Fehler Original nachladen
const srcUrl = fotoUrl.startsWith('/media/')
? fotoUrl.replace(/\.(jpe?g|png|gif|webp)$/i, '_preview.webp')
: fotoUrl;
const photoHtml = fotoUrl
? `<img class="wiki-breed-photo" src="${_esc(fotoUrl)}" loading="lazy" alt="${_esc(r.name)}" onerror="this.style.display='none';this.nextElementSibling.style.display='flex'">`
? `<img class="wiki-breed-photo" src="${_esc(srcUrl)}" loading="lazy" alt="${_esc(r.name)}"
onerror="if(this.src.includes('_preview')){this.src='${_esc(fotoUrl)}'}else{this.style.display='none';this.nextElementSibling.style.display='flex'}">`
: '';
const fallbackHtml = `<div class="wiki-breed-photo-fallback" style="${fotoUrl ? 'display:none' : ''}">${_DOG_SILHOUETTE}</div>`;
@ -746,7 +751,9 @@ window.Page_wiki = (() => {
${allFotos.map((f, i) => `
<button class="wiki-gallery-thumb${i === 0 ? ' active' : ''}" data-idx="${i}"
aria-label="Foto ${i + 1}">
<img src="${_esc(f.foto_url)}" alt="" loading="lazy">
<img src="${_esc(f.foto_url.startsWith('/media/') ? f.foto_url.replace(/\.(jpe?g|png|gif|webp)$/i,'_preview.webp') : f.foto_url)}"
alt="" loading="lazy"
onerror="if(this.src.includes('_preview')){this.src='${_esc(f.foto_url)}'}else{this.style.display='none'}">
${f.user_name ? `<span class="wiki-gallery-thumb-label">von ${_esc(f.user_name)}</span>` : ''}
</button>`).join('')}
</div>` : ''}