Skip to content

🎧 Your Personal Streaming Service

fix(share): force share image to be square (to fix aspect ratio) (#4122)

Kendall Garner5050250902a5
diff --git a/server/public/handle_images.go b/server/public/handle_images.go
index f178692f8..55a851c6f 100644
--- a/server/public/handle_images.go
+++ b/server/public/handle_images.go
@@ -37,8 +37,9 @@ func (pub *Router) handleImages(w http.ResponseWriter, r *http.Request) {
return
}
size := p.IntOr("size", 0)
+ square := p.BoolOr("square", false)
- imgReader, lastUpdate, err := pub.artwork.Get(ctx, artId, size, false)
+ imgReader, lastUpdate, err := pub.artwork.Get(ctx, artId, size, square)
switch {
case errors.Is(err, context.Canceled):
return
diff --git a/ui/src/share/SharePlayer.jsx b/ui/src/share/SharePlayer.jsx
index 38493d3ce..2c50275ed 100644
--- a/ui/src/share/SharePlayer.jsx
+++ b/ui/src/share/SharePlayer.jsx
@@ -29,7 +29,7 @@ const SharePlayer = () => {
return {
name: s.title,
musicSrc: shareStreamUrl(s.id),
- cover: shareCoverUrl(s.id),
+ cover: shareCoverUrl(s.id, true),
singer: s.artist,
duration: s.duration,
}
diff --git a/ui/src/utils/urls.js b/ui/src/utils/urls.js
index fdae496e0..5788096df 100644
--- a/ui/src/utils/urls.js
+++ b/ui/src/utils/urls.js
@@ -33,8 +33,14 @@ export const shareDownloadUrl = (id) => {
return shareUrl(config.publicBaseUrl + '/d/' + id)
}
-export const shareCoverUrl = (id) => {
- return shareUrl(config.publicBaseUrl + '/img/' + id + '?size=300')
+export const shareCoverUrl = (id, square) => {
+ return shareUrl(
+ config.publicBaseUrl +
+ '/img/' +
+ id +
+ '?size=300' +
+ (square ? '&square=true' : ''),
+ )
}
export const docsUrl = (path) => `https://www.navidrome.org${path}`