Skip to content

Commit

Permalink
Fixes problem when using absolute media source url
Browse files Browse the repository at this point in the history
  • Loading branch information
luixal committed Apr 7, 2024
1 parent f050363 commit d0f258f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions media-source-image-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class MediaSourceImageCard extends HTMLElement {
getMediaUrl(url) {
return new Promise(
resolve => {
if (this.config.image.indexOf('media-source://') == -1) return resolve({url});
if (url.indexOf('media-source://') == -1) return resolve({url});
return resolve(this._hass.callWS({
type: "media_source/resolve_media",
media_content_id: url
Expand All @@ -86,11 +86,11 @@ class MediaSourceImageCard extends HTMLElement {
}

async getImageUrl(image) {
// if template, resolve rendered template:
if (this.config.image.indexOf('{{') > -1) return this.getMediaUrl(await this.renderTemplate(image));
if (this.config.image.indexOf('[[[') > -1) return this.getMediaUrl(await this.renderJsTemplate(image));
// else, call HA service to get media source url:
return this.getMediaUrl(image);
// if template, resolve rendered template:
if (this.config.image.indexOf('{{') > -1) return this.getMediaUrl(await this.renderTemplate(image));
if (this.config.image.indexOf('[[[') > -1) return this.getMediaUrl(await this.renderJsTemplate(image));
// else, call HA service to get media source url:
return this.getMediaUrl(image);
}

setConfig(config) {
Expand Down Expand Up @@ -204,7 +204,7 @@ window.customCards.push({
});

console.info(
`%c MEDIA SOURCE IMAGE CARD %c Version 0.2.4 `,
`%c MEDIA SOURCE IMAGE CARD %c Version 0.2.5 `,
'color: orange; font-weight: bold; background: black',
'color: white; font-weight: bold; background: dimgray',
);

0 comments on commit d0f258f

Please sign in to comment.