Files
sofa/lib/tmdb/image.ts
T
jakeandClaude Opus 4.6 cd5d773e98 Add actor/cast information with person pages and search support
Integrate TMDB credits data into the app: cast carousels on title detail
pages, person detail pages with biography and filmography, and person
search results in the command palette. Includes new persons/titleCast
DB tables, profile image caching, and a nightly credits refresh cron job.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 14:36:39 -05:00

28 lines
760 B
TypeScript

import type { ImageCategory } from "@/lib/services/image-cache";
const IMAGE_BASE_URL =
process.env.TMDB_IMAGE_BASE_URL || "https://image.tmdb.org/t/p";
function sizeToCategory(size: string): ImageCategory {
if (size === "w92") return "logos";
if (size === "w185") return "profiles";
if (size === "w1280") return "backdrops";
return "posters";
}
export function tmdbImageUrl(
path: string | null,
size = "w500",
category?: ImageCategory,
) {
if (!path) return null;
if (process.env.IMAGE_CACHE_ENABLED === "false") {
return `${IMAGE_BASE_URL}/${size}${path}`;
}
const resolved = category ?? sizeToCategory(size);
const filename = path.startsWith("/") ? path.slice(1) : path;
return `/api/images/${resolved}/${filename}`;
}