From 31e003e6f343ffd5f831e25425b9d4533bb07c43 Mon Sep 17 00:00:00 2001 From: Deluan Date: Thu, 6 Mar 2025 23:32:27 -0500 Subject: [PATCH] feat(ui): use webp for login backgrounds Signed-off-by: Deluan --- server/backgrounds/handler.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/backgrounds/handler.go b/server/backgrounds/handler.go index 87f99b767..61b7d48b8 100644 --- a/server/backgrounds/handler.go +++ b/server/backgrounds/handler.go @@ -19,7 +19,7 @@ import ( const ( //imageHostingUrl = "https://unsplash.com/photos/%s/download?fm=jpg&w=1600&h=900&fit=max" - imageHostingUrl = "https://www.navidrome.org/images/%s.jpg" + imageHostingUrl = "https://www.navidrome.org/images/%s.webp" imageListURL = "https://www.navidrome.org/images/index.yml" imageListTTL = 24 * time.Hour imageCacheDir = "backgrounds" @@ -62,7 +62,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } defer s.Close() - w.Header().Set("content-type", "image/jpeg") + w.Header().Set("content-type", "image/webp") _, _ = io.Copy(w, s.Reader) } @@ -131,6 +131,10 @@ func (h *Handler) getImageList(ctx context.Context) ([]string, error) { } func imageURL(imageName string) string { - imageName = strings.TrimSuffix(imageName, ".jpg") + // Discard extension + parts := strings.Split(imageName, ".") + if len(parts) > 1 { + imageName = parts[0] + } return fmt.Sprintf(imageHostingUrl, imageName) }