refactor(web): every cover thumbnail goes through Cover, so a failed load falls back (DRY W2)

Seven places drew their own cover image. The Missing, Suspect sources,
Hidden and Reports rows showed a Music2 icon only when the track had no
album; a cover that failed to load (not fetched yet, or gone) showed a
broken image. The queue row, play bar and Now Playing each set the
placeholder in their own onerror, and the playlist card's images had no
fallback at all.

Cover gains fallback="track" (the Music2 icon a track row uses), and all
seven go through it, so each one handles a missing src and a failed load
the same way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-27 03:09:15 -05:00
co-authored by Claude Opus 5.5
parent cceeaeb5c8
commit dae46ea980
11 changed files with 80 additions and 100 deletions
+8 -16
View File
@@ -12,7 +12,8 @@
toggleQueueDrawer
} from '#lib/player/store.svelte.js';
import { formatDuration } from '#lib/media/duration.js';
import { FALLBACK_COVER, coverUrl } from '#lib/media/covers.js';
import { coverUrl } from '#lib/media/covers.js';
import Cover from './Cover.svelte';
import { dominantColorFromUrl, rgbToCssString } from '#lib/media/dominantColor.js';
import { useSmoothPosition } from '#lib/player/smoothPosition.svelte.js';
import LikeButton from './LikeButton.svelte';
@@ -32,9 +33,6 @@
const onSeekInput = (e: Event) => seekTo(inputNumber(e));
const onVolumeInput = (e: Event) => setVolume(inputNumber(e));
function onCoverError(e: Event) {
(e.currentTarget as HTMLImageElement).src = FALLBACK_COVER;
}
// Dominant-color accent. Sample the current track's cover and
// pipe it into a CSS custom property; a 2px strip above the bar
@@ -105,12 +103,9 @@
class="flex min-w-0 items-center gap-2 focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-accent"
style="flex: 1 1 35%;"
>
<img
src={coverUrl(current.album_id)}
alt=""
class="h-12 w-12 shrink-0 rounded-md object-cover"
onerror={onCoverError}
/>
<div class="h-12 w-12 shrink-0 overflow-hidden rounded-md">
<Cover src={coverUrl(current.album_id)} />
</div>
<div class="min-w-0">
<div class="truncate text-sm font-medium text-text-primary">{current.title}</div>
<div class="truncate text-xs text-text-secondary">{current.artist_name}</div>
@@ -267,12 +262,9 @@
aria-label="Open now playing"
class="shrink-0 focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-accent"
>
<img
src={coverUrl(current.album_id)}
alt=""
class="h-24 w-24 rounded-md object-cover"
onerror={onCoverError}
/>
<div class="h-24 w-24 overflow-hidden rounded-md">
<Cover src={coverUrl(current.album_id)} />
</div>
</a>
<!-- Sized to the 96px cover beside it: the title reads at body size,
as Android's mini player gives it title weight. -->