mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-04-12 12:01:58 +01:00
fix: posters
This commit is contained in:
@@ -36,6 +36,10 @@ export const getBackdropUrl = ({
|
||||
params.append("fillWidth", width.toString());
|
||||
}
|
||||
|
||||
if (item.Type === "Episode") {
|
||||
return getPrimaryImageUrl({ api, item, quality, width });
|
||||
}
|
||||
|
||||
if (backdropImageTags) {
|
||||
params.append("tag", backdropImageTags);
|
||||
return `${api.basePath}/Items/${
|
||||
|
||||
@@ -21,15 +21,29 @@ export const getLogoImageUrlById = ({
|
||||
return null;
|
||||
}
|
||||
|
||||
const imageTags = item.ImageTags?.["Logo"];
|
||||
|
||||
if (!imageTags) return null;
|
||||
|
||||
const params = new URLSearchParams();
|
||||
|
||||
params.append("tag", imageTags);
|
||||
params.append("quality", "90");
|
||||
params.append("fillHeight", height.toString());
|
||||
|
||||
if (item.Type === "Episode") {
|
||||
const imageTag = item.ParentLogoImageTag;
|
||||
const parentId = item.ParentLogoItemId;
|
||||
|
||||
if (!parentId || !imageTag) {
|
||||
return null;
|
||||
}
|
||||
|
||||
params.append("tag", imageTag);
|
||||
|
||||
return `${api.basePath}/Items/${parentId}/Images/Logo?${params.toString()}`;
|
||||
}
|
||||
|
||||
const imageTag = item.ImageTags?.["Logo"];
|
||||
|
||||
if (!imageTag) return null;
|
||||
|
||||
params.append("tag", imageTag);
|
||||
|
||||
return `${api.basePath}/Items/${item.Id}/Images/Logo?${params.toString()}`;
|
||||
};
|
||||
|
||||
42
utils/jellyfin/image/getParentBackdropImageUrl.ts
Normal file
42
utils/jellyfin/image/getParentBackdropImageUrl.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { Api } from "@jellyfin/sdk";
|
||||
import {
|
||||
BaseItemDto,
|
||||
BaseItemPerson,
|
||||
} from "@jellyfin/sdk/lib/generated-client/models";
|
||||
import { isBaseItemDto } from "../jellyfin";
|
||||
|
||||
/**
|
||||
* 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()}`;
|
||||
};
|
||||
42
utils/jellyfin/image/getPrimaryParentImageUrl.ts
Normal file
42
utils/jellyfin/image/getPrimaryParentImageUrl.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { Api } from "@jellyfin/sdk";
|
||||
import {
|
||||
BaseItemDto,
|
||||
BaseItemPerson,
|
||||
} from "@jellyfin/sdk/lib/generated-client/models";
|
||||
import { isBaseItemDto } from "../jellyfin";
|
||||
|
||||
/**
|
||||
* 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 getPrimaryParentImageUrl = ({
|
||||
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.ParentId;
|
||||
const primaryTag = item.ParentPrimaryImageTag?.[0];
|
||||
|
||||
const params = new URLSearchParams({
|
||||
fillWidth: width ? String(width) : "500",
|
||||
quality: quality ? String(quality) : "80",
|
||||
tag: primaryTag || "",
|
||||
});
|
||||
|
||||
return `${
|
||||
api?.basePath
|
||||
}/Items/${parentId}/Images/Primary?${params.toString()}`;
|
||||
};
|
||||
Reference in New Issue
Block a user