Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Clean up panic messages #14571

@jmooring

Description

@jmooring

These messages and/or logic are no longer accurate/optimal:

hugo/resources/transform.go

Lines 395 to 405 in 5594b28

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")
}
r.init(false, false)
return img
}

For example, when using Width against an .ico file you get this:

error calling Width: this method is only available for image resources

But an .ico file is an image resource per reflect.IsImageResource.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions