Files
otunes/apps/web/lib/cover-urls.ts
joshuafhigginsandremhelper 3c721d9584 feat: optimize cover image delivery (#16)
- Add sized, resized WebP cover responses
- Request appropriately sized artwork in mobile

---------

Co-authored-by: Rem Helper <remhelper@abunchofknowitalls.com>
Reviewed-on: https://git.abunchofknowitalls.com/joshuafhiggins/otunes/pulls/16
2026-08-19 11:42:31 -04:00

18 lines
624 B
TypeScript

export type CoverImageSize = 64 | 128 | 192 | 256 | 384 | 512 | 768 | 1024
function withCoverImageSize(uri: string, size?: CoverImageSize) {
return size ? `${uri}?size=${size}` : uri
}
export function artistCoverUrl(artistId: string, size?: CoverImageSize) {
return withCoverImageSize(`/api/artist/${artistId}/cover`, size)
}
export function albumCoverUrl(albumId: string, size?: CoverImageSize) {
return withCoverImageSize(`/api/album/${albumId}/cover`, size)
}
export function playlistCoverUrl(playlistId: string, size?: CoverImageSize) {
return withCoverImageSize(`/api/playlist/${playlistId}/cover`, size)
}