Refactor tmdbImageUrl to accept semantic category instead of size string

- Change primary argument from TMDB size string (`w500`, `w1280`, etc.)
  to category name (`posters`, `backdrops`, `stills`, `logos`,
  `profiles`); optional size override remains as third argument
- Update all call sites across services, actions, pages, and route
  handlers to use the new category-based API
- Update image.test.ts to match the new signature and replace
  size-mapping test descriptions with category-name descriptions
This commit is contained in:
2026-03-08 12:33:07 -04:00
parent a7b3600d15
commit ad8ec62317
14 changed files with 77 additions and 68 deletions
+1 -1
View File
@@ -316,6 +316,6 @@ export function getCastForTitle(titleId: string): CastMember[] {
return rows.map((r) => ({
...r,
profilePath: tmdbImageUrl(r.profilePath, "w185"),
profilePath: tmdbImageUrl(r.profilePath, "profiles"),
}));
}
+1 -1
View File
@@ -505,7 +505,7 @@ export function getRecommendationsForTitle(titleId: string) {
tmdbId: r.tmdbId,
type: r.type as "movie" | "tv",
title: r.title,
posterPath: tmdbImageUrl(r.posterPath, "w500"),
posterPath: tmdbImageUrl(r.posterPath, "posters"),
releaseDate: r.releaseDate,
firstAirDate: r.firstAirDate,
voteAverage: r.voteAverage,
+4 -4
View File
@@ -610,7 +610,7 @@ function fetchSeasonsFromDb(titleId: string): Season[] {
episodeNumber: ep.episodeNumber,
name: ep.name,
overview: ep.overview,
stillPath: tmdbImageUrl(ep.stillPath, "w1280", "stills"),
stillPath: tmdbImageUrl(ep.stillPath, "stills"),
airDate: ep.airDate,
runtimeMinutes: ep.runtimeMinutes,
});
@@ -763,7 +763,7 @@ function readAvailability(
.map((a) => ({
providerId: a.providerId,
providerName: a.providerName,
logoPath: tmdbImageUrl(a.logoPath, "w92"),
logoPath: tmdbImageUrl(a.logoPath, "logos"),
offerType: a.offerType,
watchUrl: generateProviderUrl(a.providerId, titleName),
}));
@@ -852,8 +852,8 @@ export async function getOrFetchTitle(id: string): Promise<{
overview: title.overview,
releaseDate: title.releaseDate,
firstAirDate: title.firstAirDate,
posterPath: tmdbImageUrl(title.posterPath, "w500"),
backdropPath: tmdbImageUrl(title.backdropPath, "w1280"),
posterPath: tmdbImageUrl(title.posterPath, "posters"),
backdropPath: tmdbImageUrl(title.backdropPath, "backdrops"),
popularity: title.popularity,
voteAverage: title.voteAverage,
voteCount: title.voteCount,
+5 -5
View File
@@ -46,7 +46,7 @@ export async function getOrFetchPerson(
birthday: details.birthday,
deathday: details.deathday,
placeOfBirth: details.place_of_birth,
profilePath: tmdbImageUrl(details.profile_path, "w185"),
profilePath: tmdbImageUrl(details.profile_path, "profiles"),
knownForDepartment: details.known_for_department,
imdbId: details.imdb_id,
};
@@ -63,7 +63,7 @@ export async function getOrFetchPerson(
birthday: person.birthday,
deathday: person.deathday,
placeOfBirth: person.placeOfBirth,
profilePath: tmdbImageUrl(person.profilePath, "w185"),
profilePath: tmdbImageUrl(person.profilePath, "profiles"),
knownForDepartment: person.knownForDepartment,
imdbId: person.imdbId,
};
@@ -116,7 +116,7 @@ export async function getOrFetchPersonByTmdbId(
birthday: person.birthday,
deathday: person.deathday,
placeOfBirth: person.placeOfBirth,
profilePath: tmdbImageUrl(person.profilePath, "w185"),
profilePath: tmdbImageUrl(person.profilePath, "profiles"),
knownForDepartment: person.knownForDepartment,
imdbId: person.imdbId,
};
@@ -151,7 +151,7 @@ export function getLocalFilmography(personId: string): PersonCredit[] {
tmdbId: r.tmdbId,
type: r.type as "movie" | "tv",
title: r.title,
posterPath: tmdbImageUrl(r.posterPath, "w500"),
posterPath: tmdbImageUrl(r.posterPath, "posters"),
releaseDate: r.releaseDate,
firstAirDate: r.firstAirDate,
voteAverage: r.voteAverage,
@@ -245,7 +245,7 @@ export async function fetchFullFilmography(
tmdbId: c.id,
type: c.media_type as "movie" | "tv",
title: c.title ?? c.name ?? "Unknown",
posterPath: tmdbImageUrl(c.poster_path, "w500"),
posterPath: tmdbImageUrl(c.poster_path, "posters"),
releaseDate: c.release_date ?? null,
firstAirDate: c.first_air_date ?? null,
voteAverage: c.vote_average,