Files
streamyfin/utils/jellyfin/image/getParentBackdropImageUrl.ts
Gauvain 5f39622ad6
Some checks failed
🤖 Android APK Build / 🏗️ Build Android APK (push) Has been cancelled
🤖 iOS IPA Build / 🏗️ Build iOS IPA (push) Has been cancelled
🔒 Lockfile Consistency Check / 🔍 Check bun.lock and package.json consistency (push) Has been cancelled
🛡️ CodeQL Analysis / 🔎 Analyze with CodeQL (javascript-typescript) (push) Has been cancelled
🏷️🔀Merge Conflict Labeler / 🏷️ Labeling Merge Conflicts (push) Has been cancelled
🕒 Handle Stale Issues / 🗑️ Cleanup Stale Issues (push) Has been cancelled
fix: bump biome and fix error (#864)
2025-07-21 09:44:24 +02:00

39 lines
962 B
TypeScript

import type { Api } from "@jellyfin/sdk";
import { type BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
/**
* Retrieves the primary image URL for a given item.
*
* @param api - The Jellyfin API instance.
* @param item - The media item to retrieve the backdrop image URL for.
* @param quality - The desired image quality (default: 90).
*/
export const getParentBackdropImageUrl = ({
api,
item,
quality = 80,
width = 400,
}: {
api?: Api | null;
item?: BaseItemDto | null;
quality?: number | null;
width?: number | null;
}) => {
if (!item || !api) {
return null;
}
const parentId = item.ParentBackdropItemId;
const tag = item.ParentBackdropImageTags?.[0] || "";
const params = new URLSearchParams({
fillWidth: width ? String(width) : "500",
quality: quality ? String(quality) : "80",
tag: tag,
});
return `${
api?.basePath
}/Items/${parentId}/Images/Backdrop/0?${params.toString()}`;
};