resources: Improve error message on .Resize etc. on SVGs

Fixes #9875
This commit is contained in:
Bjørn Erik Pedersen
2022-05-25 18:06:20 +02:00
parent 3854a6fa6c
commit bb232a351a
2 changed files with 32 additions and 1 deletions

View File

@@ -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