From 680b6c9f339d5b99b4e1af79b6bcad529bb7c4da Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Thu, 30 Nov 2023 13:09:29 -0500 Subject: [PATCH] Add icon support to cardImage --- src/components/cardbuilder/cardImage.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/cardbuilder/cardImage.ts b/src/components/cardbuilder/cardImage.ts index 087c8fc18b..05379ae683 100644 --- a/src/components/cardbuilder/cardImage.ts +++ b/src/components/cardbuilder/cardImage.ts @@ -1,9 +1,10 @@ import type { BaseItemDto } from '@jellyfin/sdk/lib/generated-client/models/base-item-dto'; +import { BaseItemKind } from '@jellyfin/sdk/lib/generated-client/models/base-item-kind'; import type { ApiClient } from 'jellyfin-apiclient'; import type { CardOptions } from 'types/cardOptions'; import { CardShape } from 'utils/card'; -import { getCardImageUrl } from './cardBuilder'; +import { getCardImageUrl, getDefaultText } from './cardBuilder'; /** * Builds an html string for a basic image only card. @@ -38,6 +39,17 @@ export function buildCardImage( const className = ` ${shape}Card`; const { blurhash, imgUrl } = image; + + let cardPadderIcon = ''; + // TV Channel logos are transparent so skip the placeholder to avoid overlapping + if (imgUrl && item.Type !== BaseItemKind.TvChannel) { + cardPadderIcon = getDefaultText(item, { + // Always use an icon + defaultCardImageIcon: 'folder', + ...options + }); + } + let blurhashAttrib = ''; if (blurhash && blurhash.length > 0) { blurhashAttrib = `data-blurhash="${blurhash}"`; @@ -47,7 +59,9 @@ export function buildCardImage( `
-
+
+ ${cardPadderIcon} +