diff options
Diffstat (limited to 'resources/images/config.go')
-rw-r--r-- | resources/images/config.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/resources/images/config.go b/resources/images/config.go index c8990d5ca..a8b5412d6 100644 --- a/resources/images/config.go +++ b/resources/images/config.go @@ -20,6 +20,7 @@ import ( "strings" "github.com/gohugoio/hugo/helpers" + "github.com/gohugoio/hugo/media" "github.com/pkg/errors" @@ -45,6 +46,15 @@ var ( ".webp": WEBP, } + imageFormatsBySubType = map[string]Format{ + media.JPEGType.SubType: JPEG, + media.PNGType.SubType: PNG, + media.TIFFType.SubType: TIFF, + media.BMPType.SubType: BMP, + media.GIFType.SubType: GIF, + media.WEBPType.SubType: WEBP, + } + // Add or increment if changes to an image format's processing requires // re-generation. imageFormatsVersions = map[Format]int{ @@ -102,6 +112,11 @@ func ImageFormatFromExt(ext string) (Format, bool) { return f, found } +func ImageFormatFromMediaSubType(sub string) (Format, bool) { + f, found := imageFormatsBySubType[sub] + return f, found +} + const ( defaultJPEGQuality = 75 defaultResampleFilter = "box" |