From 7d9f6738eb93a29693b7cc1448c0cd804bb5860f Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 6 Jul 2019 09:21:47 +0200 Subject: [PATCH] [web-src] Add helper function to append max size to artwork url --- web-src/src/components/ModalDialogAlbum.vue | 5 +---- web-src/src/pages/PageNowPlaying.vue | 5 +---- web-src/src/webapi/index.js | 10 ++++++++++ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/web-src/src/components/ModalDialogAlbum.vue b/web-src/src/components/ModalDialogAlbum.vue index 760fbc79..e8cbcb75 100644 --- a/web-src/src/components/ModalDialogAlbum.vue +++ b/web-src/src/components/ModalDialogAlbum.vue @@ -61,10 +61,7 @@ export default { computed: { artwork_url: function () { - if (this.album.artwork_url && this.album.artwork_url.startsWith('/')) { - return this.album.artwork_url + '?maxwidth=600&maxheight=600' - } - return this.album.artwork_url + return webapi.artwork_url_append_size_params(this.album.artwork_url) } }, diff --git a/web-src/src/pages/PageNowPlaying.vue b/web-src/src/pages/PageNowPlaying.vue index 4ae0b8a6..9537b2da 100644 --- a/web-src/src/pages/PageNowPlaying.vue +++ b/web-src/src/pages/PageNowPlaying.vue @@ -107,10 +107,7 @@ export default { }, artwork_url: function () { - if (this.now_playing.artwork_url && this.now_playing.artwork_url.startsWith('/')) { - return this.now_playing.artwork_url + '?maxwidth=600&maxheight=600' - } - return this.now_playing.artwork_url + return webapi.artwork_url_append_size_params(this.now_playing.artwork_url) } }, diff --git a/web-src/src/webapi/index.js b/web-src/src/webapi/index.js index a7c3f84f..82cd0e34 100644 --- a/web-src/src/webapi/index.js +++ b/web-src/src/webapi/index.js @@ -302,5 +302,15 @@ export default { spotify () { return axios.get('/api/spotify') + }, + + artwork_url_append_size_params (artworkUrl, maxwidth = 600, maxheight = 600) { + if (artworkUrl && artworkUrl.startsWith('/')) { + if (artworkUrl.includes('?')) { + return artworkUrl + '&maxwidth=' + maxwidth + '&maxheight=' + maxheight + } + return artworkUrl + '?maxwidth=' + maxwidth + '&maxheight=' + maxheight + } + return artworkUrl } }