Debian Codegraph @

docs/content/en/functions/resources/ByType.md

raw
1 ---
2 title: resources.ByType
3 description: Returns a collection of global resources of the given media type, or nil if none found.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 aliases: []
9 returnType: resource.Resources
10 signatures: [resources.ByType MEDIATYPE]
11 ---
12
13 The [media type][] is typically one of `image`, `text`, `audio`, `video`, or `application`.
14
15 ```go-html-template
16 {{ range resources.ByType "image" }}
17 <img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
18 {{ end }}
19 ```
20
21 > [!NOTE]
22 > This function operates on global resources. A global resource is a file within the `assets` directory, or within any directory mounted to the `assets` directory.
23 >
24 > For page resources, use the [`Resources.ByType`][] method on a `Page` object.
25
26 [`Resources.ByType`]: /methods/page/resources/
27 [media type]: https://en.wikipedia.org/wiki/Media_type