From fc0cdaf92324e1bffd6e1d331a1c5ec513370653 Mon Sep 17 00:00:00 2001 From: Bassel Al Sheikh Ali Date: Tue, 31 Dec 2024 09:18:21 +0300 Subject: [PATCH] fix: add Arabic font support and SVG upload --- app/handlers/images.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/handlers/images.go b/app/handlers/images.go index de2c1d452..8611c0b11 100644 --- a/app/handlers/images.go +++ b/app/handlers/images.go @@ -20,6 +20,7 @@ import ( "github.com/getfider/fider/app/pkg/log" "github.com/getfider/fider/app/pkg/web" "github.com/goenning/imagic" + "github.com/pkg/errors" ) // LetterAvatar returns a letter gravatar picture based on given name @@ -186,6 +187,7 @@ func Favicon() web.HandlerFunc { bytes, err = os.ReadFile(env.Path("public/assets/images/fav.png")) contentType = "image/png" if err != nil { + log.Error(c, errors.Wrap(err, "failed to read favicon file")) return c.Failure(err) } } @@ -199,7 +201,7 @@ func Favicon() web.HandlerFunc { opts := []imagic.ImageOperation{} if size > 0 { - opts = append(opts, imagic.Resize(size)) + opts = append(opts, imagic.FitToWidth(size)) } if c.QueryParam("bg") != "" { @@ -208,6 +210,7 @@ func Favicon() web.HandlerFunc { bytes, err = imagic.Apply(bytes, opts...) if err != nil { + log.Error(c, errors.Wrap(err, "failed to process favicon image")) return c.Failure(err) } @@ -235,7 +238,7 @@ func ViewUploadedImage() web.HandlerFunc { bytes := q.Result.Content if size > 0 { - bytes, err = imagic.Apply(bytes, imagic.Resize(size)) + bytes, err = imagic.Apply(bytes, imagic.FitToWidth(size)) if err != nil { return c.Failure(err) }