1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge pull request #4706 from TheMelmacian/feature/random_backdrop_image

Use a random backdrop image for video osd
This commit is contained in:
Bill Thornton 2023-09-14 00:19:39 -04:00 committed by GitHub
commit a7bf44bca3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 66 additions and 49 deletions

View file

@ -14,6 +14,7 @@ import alert from '../alert';
import { PluginType } from '../../types/plugin.ts';
import { includesAny } from '../../utils/container.ts';
import { getItems } from '../../utils/jellyfin-apiclient/getItems.ts';
import { getItemBackdropImageUrl } from '../../utils/jellyfin-apiclient/backdropImage';
const UNLIMITED_ITEMS = -1;
@ -154,28 +155,6 @@ function mergePlaybackQueries(obj1, obj2) {
return query;
}
function backdropImageUrl(apiClient, item, options) {
options = options || {};
options.type = options.type || 'Backdrop';
// If not resizing, get the original image
if (!options.maxWidth && !options.width && !options.maxHeight && !options.height && !options.fillWidth && !options.fillHeight) {
options.quality = 100;
}
if (item.BackdropImageTags?.length) {
options.tag = item.BackdropImageTags[0];
return apiClient.getScaledImageUrl(item.Id, options);
}
if (item.ParentBackdropImageTags?.length) {
options.tag = item.ParentBackdropImageTags[0];
return apiClient.getScaledImageUrl(item.ParentBackdropItemId, options);
}
return null;
}
function getMimeType(type, container) {
container = (container || '').toLowerCase();
@ -2693,7 +2672,7 @@ class PlaybackManager {
title: item.Name
};
const backdropUrl = backdropImageUrl(apiClient, item, {});
const backdropUrl = getItemBackdropImageUrl(apiClient, item, {}, true);
if (backdropUrl) {
resultInfo.backdropUrl = backdropUrl;
}