mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-15 18:08:17 -07:00
small improvements
This commit is contained in:
parent
8ec943bc30
commit
2b547f5a53
@ -24,12 +24,9 @@ export interface ScaleImageOptions {
|
|||||||
* @returns The url of the first or a random backdrop image of the provided item.
|
* @returns The url of the first or a random backdrop image of the provided item.
|
||||||
*/
|
*/
|
||||||
export const getItemBackdropImageUrl = (apiClient: ApiClient, item: BaseItemDto, random = false, options: ScaleImageOptions = {}): string | undefined => {
|
export const getItemBackdropImageUrl = (apiClient: ApiClient, item: BaseItemDto, random = false, options: ScaleImageOptions = {}): string | undefined => {
|
||||||
let imgUrl;
|
if (item.Id && item.BackdropImageTags?.length) {
|
||||||
|
|
||||||
if (item.BackdropImageTags?.length) {
|
|
||||||
const backdropImgIndex = random ? randomInt(0, item.BackdropImageTags.length - 1) : 0;
|
const backdropImgIndex = random ? randomInt(0, item.BackdropImageTags.length - 1) : 0;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
return apiClient.getScaledImageUrl(item.Id, {
|
||||||
imgUrl = apiClient.getScaledImageUrl(item.Id!, {
|
|
||||||
type: 'Backdrop',
|
type: 'Backdrop',
|
||||||
index: backdropImgIndex,
|
index: backdropImgIndex,
|
||||||
tag: item.BackdropImageTags[backdropImgIndex],
|
tag: item.BackdropImageTags[backdropImgIndex],
|
||||||
@ -37,19 +34,19 @@ export const getItemBackdropImageUrl = (apiClient: ApiClient, item: BaseItemDto,
|
|||||||
});
|
});
|
||||||
} else if (item.ParentBackdropItemId && item.ParentBackdropImageTags?.length) {
|
} else if (item.ParentBackdropItemId && item.ParentBackdropImageTags?.length) {
|
||||||
const backdropImgIndex = random ? randomInt(0, item.ParentBackdropImageTags.length - 1) : 0;
|
const backdropImgIndex = random ? randomInt(0, item.ParentBackdropImageTags.length - 1) : 0;
|
||||||
imgUrl = apiClient.getScaledImageUrl(item.ParentBackdropItemId, {
|
return apiClient.getScaledImageUrl(item.ParentBackdropItemId, {
|
||||||
type: 'Backdrop',
|
type: 'Backdrop',
|
||||||
index: backdropImgIndex,
|
index: backdropImgIndex,
|
||||||
tag: item.ParentBackdropImageTags[backdropImgIndex],
|
tag: item.ParentBackdropImageTags[backdropImgIndex],
|
||||||
...options
|
...options
|
||||||
});
|
});
|
||||||
} else if (item.ImageTags?.Primary) {
|
} else if (item.Id && item.ImageTags?.Primary) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
return apiClient.getScaledImageUrl(item.Id, {
|
||||||
imgUrl = apiClient.getScaledImageUrl(item.Id!, {
|
|
||||||
type: 'Primary',
|
type: 'Primary',
|
||||||
tag: item.ImageTags.Primary,
|
tag: item.ImageTags.Primary,
|
||||||
...options
|
...options
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
return undefined;
|
||||||
}
|
}
|
||||||
return imgUrl;
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user