hugo/docs/content/en/methods/resource/MediaType.md
2023-12-04 15:24:01 +01:00

1.1 KiB
Raw Blame History

title description categories keywords action
MediaType Returns a media type object for the given resource.
related returnType signatures
media.Type
RESOURCE.MediaType

The MediaType method on a Resource object returns an object with additional methods.

Methods

Type
(string) The resource's media type.
{{ with resources.Get "images/a.jpg" }}
  {{ .MediaType.Type }} → image/jpeg
{{ end }}
MainType
(string) The main type of the resources media type.
{{ with resources.Get "images/a.jpg" }}
  {{ .MediaType.MainType }} → image
{{ end }}
SubType
(string) The subtype of the resources media type. This may or may not correspond to the file suffix.
{{ with resources.Get "images/a.jpg" }}
  {{ .MediaType.SubType }} → jpeg
{{ end }}
Suffixes
(slice) A slice of possible file suffixes for the resources media type.
{{ with resources.Get "images/a.jpg" }}
  {{ .MediaType.Suffixes }} → [jpg jpeg jpe jif jfif]
{{ end }}

{{% include "methods/resource/_common/global-page-remote-resources.md" %}}