Files
2026-07-13 11:58:46 +08:00

799 B

title, description, categories, keywords, params
title description categories keywords params
Height Applicable to images, returns the height of the given resource.
functions_and_methods
returnType signatures
int
RESOURCE.Height

{{% include "/_common/methods/resource/global-page-remote-resources.md" %}}

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 }}