aboutsummaryrefslogtreecommitdiff
path: root/modules/template/template.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/template/template.go')
-rw-r--r--modules/template/template.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/modules/template/template.go b/modules/template/template.go
index 76ab66bc..6e9b15b9 100644
--- a/modules/template/template.go
+++ b/modules/template/template.go
@@ -9,6 +9,8 @@ import (
"encoding/json"
"fmt"
"html/template"
+ "mime"
+ "path/filepath"
"runtime"
"strings"
"time"
@@ -103,6 +105,10 @@ func NewFuncMap() []template.FuncMap {
"ThemeColorMetaTag": func() string {
return setting.UI.ThemeColorMetaTag
},
+ "FilenameIsImage": func(filename string) bool {
+ mimeType := mime.TypeByExtension(filepath.Ext(filename))
+ return strings.HasPrefix(mimeType, "image/")
+ },
}}
}