From ef0e7149d63c64269b852cf68a2af67b94b8eec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Fri, 22 Sep 2023 15:15:16 +0200 Subject: Add $image.Process Which supports all the existing actions: resize, crop, fit, fill. But it also allows plain format conversions: ``` {{ $img = $img.Process "webp" }} ``` Which will be a simple re-encoding of the source image. Fixes #11483 --- common/hstrings/strings.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'common') diff --git a/common/hstrings/strings.go b/common/hstrings/strings.go index 2fd791f43..88df97607 100644 --- a/common/hstrings/strings.go +++ b/common/hstrings/strings.go @@ -99,3 +99,26 @@ var reCache = regexpCache{re: make(map[string]*regexp.Regexp)} func GetOrCompileRegexp(pattern string) (re *regexp.Regexp, err error) { return reCache.getOrCompileRegexp(pattern) } + +// InSlice checks if a string is an element of a slice of strings +// and returns a boolean value. +func InSlice(arr []string, el string) bool { + for _, v := range arr { + if v == el { + return true + } + } + return false +} + +// InSlicEqualFold checks if a string is an element of a slice of strings +// and returns a boolean value. +// It uses strings.EqualFold to compare. +func InSlicEqualFold(arr []string, el string) bool { + for _, v := range arr { + if strings.EqualFold(v, el) { + return true + } + } + return false +} -- cgit v1.2.3