HUGO
Menu
GitHub 88294 stars Mastodon

MediaType

Returns a media type object for the given resource.

Syntax

RESOURCE.MediaType

Returns

media.Type

Example

{{ with resources.Get "images/a.jpg" }}
  {{ .MediaType.Type }} → image/jpeg
  {{ .MediaType.MainType }} → image
  {{ .MediaType.SubType }} → jpeg
  {{ .MediaType.Suffixes }} → [jpg jpeg jpe jif jfif]
  {{ .MediaType.FirstSuffix.Suffix }} → jpg
{{ end }}

Methods

Use these methods on the MediaType object.

Type
(string) Returns the media type.
MainType
(string) Returns the main type of the media type.
SubType
(string) Returns the subtype of the media type.
Suffixes
(slice) Returns a slice of possible file suffixes for the media type.
FirstSuffix.Suffix
(string) Returns the first of the possible file suffixes for the media type.