MediaType
Returns a media type object for the given resource.
Syntax
RESOURCE.MediaType
Returns
media.Type
Use this method with global resources, page resources, or remote resources.
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.
Last updated:
May 28, 2026
:
content: Replace h3 method sequences with description lists (c8e5b9fd2)
Improve this page