mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-03-22 20:15:07 +00:00
feat: allow use of svg, png, and ico images types for favicon (#1289)
Co-authored-by: Alessandro (Ale) Segala <43508+ItalyPaleAle@users.noreply.github.com> Co-authored-by: Kyle Mendell <kmendell@ofkm.us>
This commit is contained in:
@@ -2,7 +2,9 @@ package controller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -197,7 +199,7 @@ func (c *AppImagesController) updateBackgroundImageHandler(ctx *gin.Context) {
|
|||||||
// @Description Update the application favicon
|
// @Description Update the application favicon
|
||||||
// @Tags Application Images
|
// @Tags Application Images
|
||||||
// @Accept multipart/form-data
|
// @Accept multipart/form-data
|
||||||
// @Param file formData file true "Favicon file (.ico)"
|
// @Param file formData file true "Favicon file (.svg/.png/.ico)"
|
||||||
// @Success 204 "No Content"
|
// @Success 204 "No Content"
|
||||||
// @Router /api/application-images/favicon [put]
|
// @Router /api/application-images/favicon [put]
|
||||||
func (c *AppImagesController) updateFaviconHandler(ctx *gin.Context) {
|
func (c *AppImagesController) updateFaviconHandler(ctx *gin.Context) {
|
||||||
@@ -208,8 +210,9 @@ func (c *AppImagesController) updateFaviconHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fileType := utils.GetFileExtension(file.Filename)
|
fileType := utils.GetFileExtension(file.Filename)
|
||||||
if fileType != "ico" {
|
mimeType := utils.GetImageMimeType(strings.ToLower(fileType))
|
||||||
_ = ctx.Error(&common.WrongFileTypeError{ExpectedFileType: ".ico"})
|
if !slices.Contains([]string{"image/svg+xml", "image/png", "image/x-icon"}, mimeType) {
|
||||||
|
_ = ctx.Error(&common.WrongFileTypeError{ExpectedFileType: ".svg or .png or .ico"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
label={m.favicon()}
|
label={m.favicon()}
|
||||||
bind:image={favicon}
|
bind:image={favicon}
|
||||||
imageURL="/api/application-images/favicon"
|
imageURL="/api/application-images/favicon"
|
||||||
accept="image/x-icon"
|
accept="image/svg+xml, image/png, image/x-icon"
|
||||||
/>
|
/>
|
||||||
<ApplicationImage
|
<ApplicationImage
|
||||||
id="logo-light"
|
id="logo-light"
|
||||||
|
|||||||
Reference in New Issue
Block a user