Playlists draw a 2x2 of their first albums automatically. Owners can pick from random grids, reshuffle, or upload an image on web and mobile. Covers are rendered once into Convex storage and redrawn only when the playlist's albums change. Web and iPad sidebars show playlist covers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
27 lines
887 B
TypeScript
27 lines
887 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)
|
|
}
|
|
|
|
/** `version` is the summary's `cover`; it changes with the artwork. */
|
|
export function playlistCoverUrl(
|
|
playlistId: string,
|
|
version: string | null,
|
|
size?: CoverImageSize
|
|
) {
|
|
const params = new URLSearchParams()
|
|
if (version) params.set("v", version)
|
|
if (size) params.set("size", String(size))
|
|
const query = params.toString()
|
|
return `/api/playlist/${playlistId}/cover${query ? `?${query}` : ""}`
|
|
}
|