mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 15:28:54 +00:00
committed by
Bjørn Erik Pedersen
parent
44dc3847f4
commit
e8577771c3
@@ -97,7 +97,7 @@ Width: {{ $svg.Width }}
|
||||
}).BuildE()
|
||||
|
||||
b.Assert(err, qt.IsNotNil)
|
||||
b.Assert(err.Error(), qt.Contains, `error calling Width: this method is only available for raster images. To determine if an image is SVG, you can do {{ if eq .MediaType.SubType "svg" }}{{ end }}`)
|
||||
b.Assert(err.Error(), qt.Contains, `error calling Width: resource "/circle.svg" of media type "image/svg+xml" does not support this method: use reflect.IsImageResource, reflect.IsImageResourceProcessable, or reflect.IsImageResourceWithMeta to check if the resource supports this method before calling it`)
|
||||
}
|
||||
|
||||
// Issue 10255.
|
||||
|
||||
+12
-4
@@ -395,12 +395,20 @@ func (r resourceAdapter) WithResourceMeta(mp resource.ResourceMetaProvider) reso
|
||||
func (r *resourceAdapter) getImageOps() images.ImageResourceOps {
|
||||
img, ok := r.target.(images.ImageResourceOps)
|
||||
if !ok {
|
||||
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 }}")
|
||||
}
|
||||
panic("this method is only available for image resources")
|
||||
instructions := "use reflect.IsImageResource, " +
|
||||
"reflect.IsImageResourceProcessable, or " +
|
||||
"reflect.IsImageResourceWithMeta to check if the resource " +
|
||||
"supports this method before calling it"
|
||||
msg := fmt.Sprintf(
|
||||
"resource %q of media type %q does not support this method: %s",
|
||||
r.Name(),
|
||||
r.MediaType(),
|
||||
instructions,
|
||||
)
|
||||
panic(msg)
|
||||
}
|
||||
r.init(false, false)
|
||||
|
||||
return img
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user