Back to Hugo

reflect.IsImageResource

docs/content/en/functions/reflect/IsImageResource.md

0.161.1511 B
Original Source

{{< new-in 0.154.0 />}}

Usage

This example iterates through all project resources and uses reflect.IsImageResource to decide whether to render an image tag or provide a download link for non-image files.

go-html-template
{{ range resources.Match "**" }}
  {{ if reflect.IsImageResource . }}
    
  {{ else }}
    <a href="{{ .RelPermalink }}">Download</a>
  {{ end }}
{{ end }}

{{% include "/_common/functions/reflect/image-reflection-functions.md" %}}