From 8e75e2b1a7fc871ac6988b098e2426b8260eeff1 Mon Sep 17 00:00:00 2001 From: rene Date: Wed, 27 May 2026 09:20:10 +0200 Subject: [PATCH] Fix: previewFallback blendet kaputte Bilder aus statt Fragezeichen, SW by-v1110 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit User-Report: nach Sprint-Migration auf _preview.webp tauchen Fragezeichen-Icons auf — wenn weder Preview noch Original verfügbar. Probleme im vorigen Fix: - UI.escape() ist HTML-Escape, kein JS-String-Escape → URL mit ?param=value wurde &-encoded und damit kaputt - 'opacity:0.3' lässt das Browser-Default-Broken-Image-Icon durchscheinen (Fragezeichen sichtbar) - Kein Loop-Schutz beim onerror Fixes: - String-Escape via .replace(/'/g, \"\\'\") statt UI.escape() - display:none + .img-broken-Klasse bei finalem Fehler - dataset.fb='1' verhindert Endlos-Loop wenn Original-URL auch 404 - Wenn URL nicht mit /media/ startet: direkt ausblenden (keine Preview-Variante zu probieren) --- VERSION | 2 +- backend/static/index.html | 24 ++++++++++++------------ backend/static/js/app.js | 2 +- backend/static/js/ui.js | 11 ++++++++--- backend/static/landing.html | 2 +- backend/static/sw.js | 2 +- 6 files changed, 24 insertions(+), 19 deletions(-) diff --git a/VERSION b/VERSION index 304a6a5..96e38be 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1109 \ No newline at end of file +1110 \ No newline at end of file diff --git a/backend/static/index.html b/backend/static/index.html index 92e72d5..8f134e7 100644 --- a/backend/static/index.html +++ b/backend/static/index.html @@ -86,14 +86,14 @@ Ban Yaro - + - - - - - + + + + + @@ -617,11 +617,11 @@ - - - - - + + + + + @@ -631,7 +631,7 @@ - + diff --git a/backend/static/js/app.js b/backend/static/js/app.js index 2232ad1..600d601 100644 --- a/backend/static/js/app.js +++ b/backend/static/js/app.js @@ -3,7 +3,7 @@ Router, State-Management, Navigation, Initialisierung. ============================================================ */ -const APP_VER = '1109'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VER = '1110'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen const APP_VERSION = '1.6.0'; // ← semantische Version, wird bei make release gesetzt window.APP_VER = APP_VER; // global verfügbar für andere Module (z.B. offline-indicator) window.APP_VERSION = APP_VERSION; diff --git a/backend/static/js/ui.js b/backend/static/js/ui.js index 52710f7..6b94eee 100644 --- a/backend/static/js/ui.js +++ b/backend/static/js/ui.js @@ -295,10 +295,15 @@ const UI = (() => { if (!url || !url.startsWith('/media/')) return url || ''; return url.replace(/\.(jpe?g|png|gif|webp)$/i, '_preview.webp'); } - // onerror-Handler: bei 404 vom _preview die Original-URL nachladen + // onerror-Handler: bei 404 vom _preview die Original-URL nachladen, + // bei zweitem Fehler das Image komplett ausblenden (kein Browser-Fragezeichen). + // Setzt eine Klasse 'img-broken' damit Container ggf. einen Fallback zeigen können. function previewFallback(originalUrl) { - if (!originalUrl || !originalUrl.startsWith('/media/')) return ''; - return `if(this.src.includes('_preview')){this.src='${escape(originalUrl)}'}else{this.style.opacity='0.3'}`; + if (!originalUrl || !originalUrl.startsWith('/media/')) { + return `this.style.display='none';this.classList.add('img-broken')`; + } + const safe = String(originalUrl).replace(/'/g, "\\'"); + return `if(this.src.includes('_preview')&&!this.dataset.fb){this.dataset.fb='1';this.src='${safe}'}else{this.style.display='none';this.classList.add('img-broken')}`; } function emptyState({ icon, title, text, action } = {}) { diff --git a/backend/static/landing.html b/backend/static/landing.html index df14320..683bbad 100644 --- a/backend/static/landing.html +++ b/backend/static/landing.html @@ -4,7 +4,7 @@ - + Ban Yaro — Die Hunde-App für Deutschland, Österreich & Schweiz diff --git a/backend/static/sw.js b/backend/static/sw.js index d8de5e4..36ea39b 100644 --- a/backend/static/sw.js +++ b/backend/static/sw.js @@ -4,7 +4,7 @@ ============================================================ */ // ← EINZIGE Stelle für die Version — STATIC_ASSETS und CACHE_VERSION leiten sich ab -const VER = '1109'; +const VER = '1110'; const CACHE_VERSION = `by-v${VER}`; const CACHE_STATIC = `${CACHE_VERSION}-static`; const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten