Files
hugo/docs/content/en/functions/reflect/IsImageResource.md
T
2026-03-23 18:25:55 +01:00

816 B

title, description, categories, keywords, params
title description categories keywords params
reflect.IsImageResource Reports whether the given value is a Resource object representing an image as defined by its media type.
functions_and_methods
aliases returnType signatures
bool
reflect.IsImageResource INPUT

{{< 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.

{{ range resources.Match "**" }}
  {{ if reflect.IsImageResource . }}
    <img src="{{ .RelPermalink }}" alt="Image">
  {{ else }}
    <a href="{{ .RelPermalink }}">Download</a>
  {{ end }}
{{ end }}

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