Files
otunes/apps/web/lib/cover-urls.ts
T
joshuafhigginsandClaude Opus 5.5 Verified 886c8f0643 feat: playlist cover artwork
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>
2026-11-19 13:15:21 -05:00

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}` : ""}`
}