diff options
author | Bjørn Erik Pedersen <[email protected]> | 2022-05-25 18:06:20 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2022-05-25 18:06:20 +0200 |
commit | bb232a351ac4ceb488d06f45ef230e457be26f40 (patch) | |
tree | c5ce77034d156f082892e1d141c9cfb9a7ca6190 /resources/transform.go | |
parent | 3854a6fa6c323d1c09aa71a0626c9eef62709294 (diff) | |
download | hugo-bb232a351ac4ceb488d06f45ef230e457be26f40.tar.gz hugo-bb232a351ac4ceb488d06f45ef230e457be26f40.zip |
resources: Improve error message on .Resize etc. on SVGs
Fixes #9875
Diffstat (limited to 'resources/transform.go')
-rw-r--r-- | resources/transform.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/resources/transform.go b/resources/transform.go index bb1608cbd..7d81f9b21 100644 --- a/resources/transform.go +++ b/resources/transform.go @@ -297,7 +297,11 @@ func (r *resourceAdapter) DecodeImage() (image.Image, error) { func (r *resourceAdapter) getImageOps() images.ImageResourceOps { img, ok := r.target.(images.ImageResourceOps) if !ok { - panic(fmt.Sprintf("%T is not an image", r.target)) + if r.MediaType().SubType == "svg" { + panic("this method is only available for raster images. To determine if an image is SVG, you can do {{ if eq .MediaType.SubType \"svg\" }}{{ end }}") + } + fmt.Println(r.MediaType().SubType) + panic("this method is only available for image resources") } r.init(false, false) return img |