mirror of
https://github.com/Jellify-Music/App.git
synced 2026-03-23 13:42:09 -05:00
fix lots of images not showing up
This commit is contained in:
@@ -426,4 +426,45 @@ describe('getItemImageUrl', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('fallback - item own ID', () => {
|
||||
it('should use item ID as last resort when no image tags, album, or artists exist', () => {
|
||||
const mockItem: BaseItemDto = {
|
||||
Id: 'item-1',
|
||||
Name: 'Test Track',
|
||||
Type: 'Audio',
|
||||
// No ImageTags, no AlbumId, no AlbumArtists, no ArtistItems
|
||||
}
|
||||
|
||||
const result = getItemImageUrl(mockItem, ImageType.Primary)
|
||||
|
||||
expect(result).toBe('http://example.com/image.jpg')
|
||||
expect(mockGetItemImageUrlById).toHaveBeenCalledWith('item-1', ImageType.Primary, {
|
||||
tag: undefined,
|
||||
maxWidth: 200,
|
||||
maxHeight: 200,
|
||||
quality: 90,
|
||||
})
|
||||
})
|
||||
|
||||
it('should use item ID as last resort when album has no tag and no artists exist', () => {
|
||||
const mockItem: BaseItemDto = {
|
||||
Id: 'item-1',
|
||||
Name: 'Test Track',
|
||||
Type: 'Audio',
|
||||
AlbumId: 'album-1',
|
||||
// No AlbumPrimaryImageTag, so album fallback won't trigger
|
||||
}
|
||||
|
||||
const result = getItemImageUrl(mockItem, ImageType.Primary)
|
||||
|
||||
expect(result).toBe('http://example.com/image.jpg')
|
||||
expect(mockGetItemImageUrlById).toHaveBeenCalledWith('item-1', ImageType.Primary, {
|
||||
tag: undefined,
|
||||
maxWidth: 200,
|
||||
maxHeight: 200,
|
||||
quality: 90,
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -50,7 +50,7 @@ export function getItemImageUrl(
|
||||
...imageParams,
|
||||
tag: AlbumPrimaryImageTag ?? undefined,
|
||||
})
|
||||
} else {
|
||||
} else if (AlbumArtists?.[0]?.Id || ArtistItems?.[0]?.Id) {
|
||||
// Fall back to first artist's image (AlbumArtists or ArtistItems for slimified tracks)
|
||||
const artistId = AlbumArtists?.[0]?.Id ?? ArtistItems?.[0]?.Id
|
||||
if (artistId) {
|
||||
@@ -58,6 +58,11 @@ export function getItemImageUrl(
|
||||
...imageParams,
|
||||
})
|
||||
}
|
||||
} else if (Id) {
|
||||
// Last ditch effort: use the item's own ID without a specific type tag
|
||||
imageUrl = getImageApi(api).getItemImageUrlById(Id, type, {
|
||||
...imageParams,
|
||||
})
|
||||
}
|
||||
|
||||
return imageUrl
|
||||
|
||||
Reference in New Issue
Block a user