HUGO
Menu
GitHub 89803 stars Mastodon

Height

Returns the height of the given image resource.
Syntax
RESOURCE.Height
Returns
int

Use the reflect.IsImageResourceWithMeta function to verify that Hugo can determine the dimensions before calling the Height method.

{{ with resources.GetMatch "images/featured.*" }}
  {{ if reflect.IsImageResourceWithMeta . }}
    <img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
  {{ else }}
    <img src="{{ .RelPermalink }}" alt="">
  {{ end }}
{{ end }}