reflect.IsImageResourceWithMeta
Reports whether the given value is a Resource object representing an image with metadata.
Syntax
reflect.IsImageResourceWithMeta INPUT
Returns
bool
An image with metadata is an image format from which Hugo can extract dimensions and, if present, Exif, IPTC, and XMP data.
Usage
Use the reflect.IsImageResourceWithMeta function to determine if a resource is an image format from which metadata can be extracted.
{{ with resources.Get "image.avif" }}
{{ reflect.IsImageResourceWithMeta . }} → true
{{ end }}Formats with metadata
The following table shows the result of reflect.IsImageResourceWithMeta for various file types and their corresponding media types.
| Filename | Media Type | With Meta |
|---|---|---|
| data.json | application/json | false |
| image.avif | image/avif | true |
| image.bmp | image/bmp | false |
| image.gif | image/gif | false |
| image.heic | image/heic | true |
| image.heif | image/heif | true |
| image.jpg | image/jpeg | true |
| image.png | image/png | true |
| image.svg | image/svg+xml | false |
| image.tiff | image/tiff | true |
| image.webp | image/webp | true |
Example
You can use this function to safely extract and display metadata from a collection of images, ensuring you only call metadata methods on supported formats.
{{ range resources.ByType "image" }}
{{ if reflect.IsImageResourceWithMeta . }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}">
{{ with .Meta }}
<p>Taken on: {{ .Date }}</p>
{{ end }}
{{ end }}
{{ end }}Last updated:
February 24, 2026
:
content: Miscellaneous udpates for v0.157.0 (c3cb4363d)
Improve this page