diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/template/template.go | 6 |
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/") + }, }} } |