Skip to content

Commit

Permalink
Add icon support to cardImage
Browse files Browse the repository at this point in the history
  • Loading branch information
thornbill committed Nov 30, 2023
1 parent 92ed674 commit 680b6c9
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/components/cardbuilder/cardImage.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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}"`;
Expand All @@ -47,7 +59,9 @@ export function buildCardImage(
`<div class="card ${className}">
<div class="cardBox">
<div class="cardScalable">
<div class="cardPadder cardPadder-${shape}"></div>
<div class="cardPadder cardPadder-${shape}">
${cardPadderIcon}
</div>
<div
class="cardImageContainer coveredImage cardContent lazy"
style="cursor: default;"
Expand Down

0 comments on commit 680b6c9

Please sign in to comment.