hugo/docs/content/en/methods/resource/MediaType.md
Bjørn Erik Pedersen 5fd1e74903
Merge commit '9b0050e9aabe4be65c78ccf292a348f309d50ccd' as 'docs'
```
git subtree add --prefix=docs/ https://github.com/gohugoio/hugoDocs.git master --squash
```

Closes #11925
2024-01-27 10:48:57 +01:00

53 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: MediaType
description: Returns a media type object for the given resource.
categories: []
keywords: []
action:
related: []
returnType: media.Type
signatures: [RESOURCE.MediaType]
---
The `MediaType` method on a `Resource` object returns an object with additional methods.
## Methods
Type
: (`string`) The resource's media type.
```go-html-template
{{ with resources.Get "images/a.jpg" }}
{{ .MediaType.Type }} → image/jpeg
{{ end }}
```
MainType
: (`string`) The main type of the resources media type.
```go-html-template
{{ 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.
```go-html-template
{{ with resources.Get "images/a.jpg" }}
{{ .MediaType.SubType }} → jpeg
{{ end }}
```
Suffixes
: (`slice`) A slice of possible file suffixes for the resources media type.
```go-html-template
{{ with resources.Get "images/a.jpg" }}
{{ .MediaType.Suffixes }} → [jpg jpeg jpe jif jfif]
{{ end }}
```
{{% include "methods/resource/_common/global-page-remote-resources.md" %}}