mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 01:35:39 -04:00
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>
28 lines
760 B
TypeScript
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}`;
|
|
}
|