Skip to content

Commit

Permalink
feature: custom thumbnail
Browse files Browse the repository at this point in the history
  • Loading branch information
punxaphil committed Sep 27, 2023
1 parent 4ec1c05 commit 04e6b8e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ artworkHostname: http://192.168.0.59:8123 #default is ''. Usually not needed, bu
# media browser specific
mediaBrowserItemsPerRow: 4 # default is 1. Use this to show items as icons.
mediaBrowserShowTitleForThumbnailIcons: true # default is false. Only makes a difference if mediaBrowserItemsPerRow > 1. Will show title for thumbnail artworks.
customThumbnail:
Voyage: https://i.scdn.co/image/ab67706f000000027b2e7ee752dc222ff2fd466f
customThumbnailIfMissing:
Ed Sheeran Radio: https://i.scdn.co/image/ab6761610000e5eb4d2f80ceffc6c70a432ccd7c
Legendary: https://i.scdn.co/image/ab67706f000000027b2e7ee752dc222ff2fd466f
Expand Down
1 change: 1 addition & 0 deletions src/editor/advanced-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class AdvancedEditor extends BaseEditor {
The following needs to be configured using code (YAML):
<ul>
<li>customSources</li>
<li>customThumbnail</li>
<li>customThumbnailIfMissing</li>
<li>mediaBrowserTitlesToIgnore</li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface CardConfig extends LovelaceCardConfig {
dynamicVolumeSlider: boolean;
mediaArtworkOverrides?: MediaArtworkOverride[];
customSources?: CustomSources;
customThumbnail?: CustomThumbnail;
customThumbnailIfMissing?: CustomThumbnail;
mediaBrowserTitlesToIgnore?: string[];
mediaBrowserItemsPerRow: number;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/media-browser-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function hasItemsWithImage(items: MediaPlayerItem[]) {
return items.some((item) => item.thumbnail);
}
function getThumbnail(mediaItem: MediaPlayerItem, config: CardConfig, itemsWithImage: boolean) {
let thumbnail = mediaItem.thumbnail;
let thumbnail = config.customThumbnail?.[mediaItem.title] ?? mediaItem.thumbnail;
if (!thumbnail) {
thumbnail = config.customThumbnailIfMissing?.[mediaItem.title];
if (itemsWithImage && !thumbnail) {
Expand Down

0 comments on commit 04e6b8e

Please sign in to comment.