{"record":{"id":"cace3870082e7c7a","repo":"gohugoio/hugo","slug":"resource-q-of-media-type-q-does-not-support-this","errorCode":null,"errorMessage":"resource %q of media type %q does not support this method: %s","messagePattern":"resource %q of media type %q does not support this method: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/transform.go","lineNumber":414,"sourceCode":"func (r resourceAdapter) WithResourceMeta(mp resource.ResourceMetaProvider) resource.Resource {\n\tr.metaProvider = mp\n\treturn &r\n}\n\nfunc (r *resourceAdapter) getImageOps() images.ImageResourceOps {\n\timg, ok := r.target.(images.ImageResourceOps)\n\tif !ok {\n\t\tinstructions := \"use reflect.IsImageResource, \" +\n\t\t\t\"reflect.IsImageResourceProcessable, or \" +\n\t\t\t\"reflect.IsImageResourceWithMeta to check if the resource \" +\n\t\t\t\"supports this method before calling it\"\n\t\tmsg := fmt.Sprintf(\n\t\t\t\"resource %q of media type %q does not support this method: %s\",\n\t\t\tr.Name(),\n\t\t\tr.MediaType(),\n\t\t\tinstructions,\n\t\t)\n\t\tpanic(msg)\n\t}\n\tr.init(false, false)\n\n\treturn img\n}\n\n// ResolveImageOpsSupport reports the ImageOpsSupport for the given resource. This can be used to determine if a resource supports image operations like Resize, Crop, etc.\nfunc ResolveImageOpsSupport(v any) images.ImageResourceType {\n\tr, ok := v.(resource.Resource)\n\tif !ok {\n\t\treturn images.ImageResourceTypeNone\n\t}\n\tmt := r.MediaType()\n\tif mt.MainType != \"image\" {\n\t\treturn images.ImageResourceTypeNone\n\t}\n\t_, support := images.ImageFormatFromMediaSubType(mt.SubType)\n\treturn support","sourceCodeStart":396,"sourceCodeEnd":432,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/transform.go#L396-L432","documentation":"Thrown by resourceAdapter.getImageOps() (transform.go:401-415) when the underlying target does not implement images.ImageResourceOps, i.e. the resource is not a processable image. The panic includes the resource name, media type, and explicit instructions to check support with reflect.IsImageResource / IsImageResourceProcessable / IsImageResourceWithMeta before calling image methods.","triggerScenarios":"Calling an image method (Resize, Crop, Fit, Fill, Filter/Process, DecodeImage, etc.) on a resource whose media type is not an image, or whose subtype is not a supported image format. The method dispatch happens lazily inside getImageOps.","commonSituations":"A page bundles a PDF or SVG expecting Resize to work; a non-image resource is passed through a generic image-processing partial; or the media type is misconfigured (e.g. wrong MIME for a WebP).","solutions":["Use reflect.IsImageResource / IsImageResourceProcessable to guard before calling image methods.","Confirm the resource's MediaType is an image subtype Hugo can process (jpeg/png/gif/webp/tiff/bmp).","Note SVG is generally not raster-processable; convert or handle separately."],"exampleFix":"// before\n{{ $img := $r.Resize \"100x100\" }}\n// after\n{{ if reflect.IsImageResourceProcessable $r }}\n  {{ $img := $r.Resize \"100x100\" }}\n{{ end }}","handlingStrategy":"type-guard","validationCode":"{{ if reflect.IsImageResourceProcessable $r }}\n  {{ $img := $r.Resize \"100x100\" }}\n{{ else }}\n  {{ errorf \"resource %s is not a processable image\" $r.Name }}\n{{ end }}","typeGuard":"// IsProcessableImage reports whether r supports image operations.\nfunc IsProcessableImage(r resource.Resource) bool {\n    return images.ResolveImageOpsSupport(r) != images.ImageResourceTypeNone\n}","tryCatchPattern":null,"preventionTips":["Guard every image method call with reflect.IsImageResource / IsImageResourceProcessable.","Confirm media type is an image subtype before processing.","Handle SVG/PDF separately from raster image processing."],"tags":["resource","image","type-guard","media-type","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}