[web-src] Add helper function to append max size to artwork url

This commit is contained in:
chme 2019-07-06 09:21:47 +02:00
parent 02478becf0
commit 7d9f6738eb
3 changed files with 12 additions and 8 deletions

View File

@ -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)
}
},

View File

@ -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)
}
},

View File

@ -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
}
}