mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 15:28:54 +00:00
816 B
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. |
|
{{< 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" %}}