From c49f16459053ba1a65b6b999791e31bb696059de Mon Sep 17 00:00:00 2001 From: decentral1se Date: Fri, 4 Feb 2022 20:41:19 +0100 Subject: [PATCH] fix: show original image if can't thumbnail See https://git.vvvvvvaria.org/decentral1se/distribusi-go/issues/5 --- distribusi.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/distribusi.go b/distribusi.go index 0e0ead2..cccfb29 100644 --- a/distribusi.go +++ b/distribusi.go @@ -453,14 +453,8 @@ func getMtype(fpath string) (string, error) { // genThumb generates an in-memory image thumbnail and encodes it into a base64 // representation which is suitable for embedding in HTML pages. func genThumb(c *cli.Context, fpath, caption string) (string, error) { - knownFailureExts := []string{".ico", ".svg", ".xcf"} - if sliceContains(knownFailureExts, filepath.Ext(fpath)) { - return "", fmt.Errorf("unable to generate thumbnail for %s", fpath) - } - imgSrc, err := imaging.Open(fpath, imaging.AutoOrientation(true)) if err != nil { - logrus.Debugf("failed to generate thumbnail for %s", fpath) return "", err } @@ -577,8 +571,8 @@ func getHref(c *cli.Context, fpath string, mtype string) (bool, string, error) { } else { thumb, err := genThumb(c, fpath, caption) if err != nil { - unknown = true - href = fmt.Sprintf("%s", stype, fname, fname) + logrus.Debugf("failed to generate thumbnail for %s, showing original image", fpath) + href = fmt.Sprintf("", stype, fname) } else { href = fmt.Sprintf( "
%s
",