HUGO
Menu
GitHub 86778 stars Mastodon

reflect.IsImageResource

Reports whether the given value is a Resource object representing an image as defined by its media type.

Syntax

reflect.IsImageResource INPUT

Returns

bool
New in v0.154.0

The following example demonstrates how to check if a resource is categorized as an image.

{{ with resources.Get "image.jpg" }}
  {{ .MediaType.MainType }}           → image
  {{ reflect.IsImageResource . }}     → true
{{ end }}

{{ with resources.Get "data.json" }}
  {{ .MediaType.MainType }}           → application
  {{ reflect.IsImageResource . }}     → false
{{ end }}