feat: generate and display thumbhash blur placeholders for TMDB images

This commit is contained in:
2026-03-14 18:58:09 -04:00
parent 76648a6023
commit aede4fc90a
49 changed files with 4294 additions and 287 deletions
+12 -4
View File
@@ -8,7 +8,7 @@ export type ImageCategory =
const IMAGE_BASE_URL =
process.env.TMDB_IMAGE_BASE_URL || "https://image.tmdb.org/t/p";
const CATEGORY_SIZES: Record<ImageCategory, string> = {
export const IMAGE_CATEGORY_SIZES: Record<ImageCategory, string> = {
posters: "w500",
backdrops: "w1280",
stills: "w1280",
@@ -16,6 +16,16 @@ const CATEGORY_SIZES: Record<ImageCategory, string> = {
profiles: "w185",
};
export function tmdbCdnImageUrl(
path: string | null,
category: ImageCategory,
sizeOverride?: string,
) {
if (!path) return null;
const size = sizeOverride ?? IMAGE_CATEGORY_SIZES[category];
return `${IMAGE_BASE_URL}/${size}${path}`;
}
export function tmdbImageUrl(
path: string | null,
category: ImageCategory,
@@ -23,10 +33,8 @@ export function tmdbImageUrl(
) {
if (!path) return null;
const size = sizeOverride ?? CATEGORY_SIZES[category];
if (process.env.IMAGE_CACHE_ENABLED === "false") {
return `${IMAGE_BASE_URL}/${size}${path}`;
return tmdbCdnImageUrl(path, category, sizeOverride);
}
const filename = path.startsWith("/") ? path.slice(1) : path;