From a6359a26903652c26631a99161a8ae16b24b00db Mon Sep 17 00:00:00 2001
From: Broque Thomas <26755000+Nezreka@users.noreply.github.com>
Date: Fri, 24 Apr 2026 08:41:07 -0700
Subject: [PATCH] Add fallbacks for search result images
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Self-audit catch: my earlier cover-art commit claimed 'the frontend's
fallback handles 404s' โ that was wrong. The enhanced
search result images in shared-helpers.js renderCompactSection and all
five gsearch-item/track templates in downloads.js render bare
`` with no fallback. With the MusicBrainz adapter now
emitting Cover Art Archive URLs deterministically (no HEAD probe),
albums that don't have cover art would show the browser's broken-image
icon instead of the emoji placeholder.
Two fallback shapes:
- shared-helpers.js renderCompactSection: the `` sits inside a
card with a sibling placeholder pattern. On error, replace the img's
outerHTML with the placeholder div, matching the shape used when
config.image is missing entirely.
- downloads.js gsearch items: the `` sits inside a
`.gsearch-item-art` div whose default text content is the emoji fallback
(๐ค / ๐ฟ / ๐ถ / ๐ต). On error, set parentElement.textContent to the
emoji, which wipes the img and shows the glyph. Same shape as the
"no image_url" branch.
Applies to every card type that renders a user-provided image URL so
the fix covers all sources that might return 404s โ MB is the most
common offender but iTunes/Deezer/Discogs can all miss too.
Tested against the live MB API: Metallica albums without CAA cover art
now show the ๐ฟ emoji instead of a broken-image icon.
---
webui/static/downloads.js | 10 +++++-----
webui/static/shared-helpers.js | 10 ++++++++--
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/webui/static/downloads.js b/webui/static/downloads.js
index ce20e659..0f89ed7d 100644
--- a/webui/static/downloads.js
+++ b/webui/static/downloads.js
@@ -5333,13 +5333,13 @@ function _gsRenderFromState(state) {
if (dbArtists.length) {
h += '
`;
}).join('');
h += '';
}
diff --git a/webui/static/shared-helpers.js b/webui/static/shared-helpers.js
index 660ef01c..ce65a412 100644
--- a/webui/static/shared-helpers.js
+++ b/webui/static/shared-helpers.js
@@ -559,9 +559,15 @@ function renderCompactSection(sectionId, listId, countId, items, mapItem) {
placeholderClass += ' track-placeholder';
}
+ // Fallback placeholder used when the image 404s (common for MB
+ // Cover Art Archive URLs โ we construct them deterministically
+ // without probing first, so some will miss). Without onerror the
+ // browser shows its broken-image icon.
+ const placeholderHtml = `