fix(ui): serve the placeholder for known-absent art instead of a broken icon

getCoverArtUrl returned '' for an imageAbsent record, so <img src={undefined}> rendered as the browser's broken-image icon on every absent cover. The server already serves a proper placeholder for absent art, so build the url and let it render.
This commit is contained in:
Deluan 2026-07-24 12:24:12 -04:00
parent a1eb5e8343
commit 20557f2fb8
2 changed files with 9 additions and 12 deletions

View File

@ -81,10 +81,6 @@ const getAvatarUrl = (username, size) =>
)
const getCoverArtUrl = (record, size, square) => {
// Known-absent art would only ever return a placeholder; skip the round trip entirely.
if (record.imageAbsent) {
return ''
}
const suffix = record.imageHash ? '_' + record.imageHash : ''
const options = {
// A hash-suffixed url is already pixel-versioned; the buster would defeat immutable caching.

View File

@ -151,14 +151,15 @@ describe('getCoverArtUrl', () => {
expect(url).toContain('_=')
})
it('returns an empty url for known-absent artwork', () => {
expect(
subsonic.getCoverArtUrl({
id: 'album-123',
albumArtist: 'AA',
imageAbsent: true,
}),
).toBe('')
it('still builds a url for known-absent artwork so the server placeholder renders', () => {
// Returning '' here made <img src=undefined> render as a broken icon; the server serves a
// proper placeholder for absent art, so the client must still request it.
const url = subsonic.getCoverArtUrl({
id: 'album-123',
albumArtist: 'AA',
imageAbsent: true,
})
expect(url).toContain('al-album-123')
})
})