mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-09-15 01:34:41 -04:00
Disambiguate global and page resources
There are 2 different kind of resource, one that is attached to the page, matching all non-rendered files, and the global one matching all files in `/assets`. Although they have similar behaviour, the way to access both of them are slightly different. Explicitly express differences between both and clarify when a page is attached resources and when not.
This commit is contained in:
parent
5e233dc4bb
commit
95bd7974ee
@ -18,14 +18,23 @@ menu:
|
|||||||
|
|
||||||
The `image` is a [Page Resource]({{< relref "/content-management/page-resources" >}}), and the processing methods listed below do not work on images inside your `/static` folder.
|
The `image` is a [Page Resource]({{< relref "/content-management/page-resources" >}}), and the processing methods listed below do not work on images inside your `/static` folder.
|
||||||
|
|
||||||
To get all images in a [Page Bundle]({{< relref "/content-management/organization#page-bundles" >}}):
|
To print all images paths in a [Page Bundle]({{< relref "/content-management/organization#page-bundles" >}}):
|
||||||
|
|
||||||
```go-html-template
|
```go-html-template
|
||||||
{{ with .Resources.ByType "image" }}
|
{{ with .Resources.ByType "image" }}
|
||||||
|
{{ range . }}
|
||||||
|
{{ .RelPermalink }}
|
||||||
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## The Image Resource
|
||||||
|
|
||||||
|
The `image` resource can also be retrieved from a [global resource]({{< relref "/hugo-pipes/introduction#from-file-to-resource" >}})
|
||||||
|
|
||||||
|
{{- $image := resources.Get "images/logo.jpg" -}}
|
||||||
|
|
||||||
## Image Processing Methods
|
## Image Processing Methods
|
||||||
|
|
||||||
The `image` resource implements the methods `Resize`, `Fit` and `Fill`, each returning the transformed image using the specified dimensions and processing options. The `image` resource also, since Hugo 0.58, implements the method `Exif` and `Filter`.
|
The `image` resource implements the methods `Resize`, `Fit` and `Fill`, each returning the transformed image using the specified dimensions and processing options. The `image` resource also, since Hugo 0.58, implements the method `Exif` and `Filter`.
|
||||||
|
@ -73,6 +73,14 @@ my-post
|
|||||||
: This leaf bundle has the `index.md`, two other content
|
: This leaf bundle has the `index.md`, two other content
|
||||||
Markdown files and two image files.
|
Markdown files and two image files.
|
||||||
|
|
||||||
|
image1
|
||||||
|
: This image is a page resource of `my-post`
|
||||||
|
and only available in `my-post/index.md` resources.
|
||||||
|
|
||||||
|
image2
|
||||||
|
: This image is a page resource of `my-post`
|
||||||
|
and only available in `my-post/index.md` resources.
|
||||||
|
|
||||||
my-other-post
|
my-other-post
|
||||||
: This leaf bundle has only the `index.md`.
|
: This leaf bundle has only the `index.md`.
|
||||||
|
|
||||||
|
@ -14,6 +14,10 @@ menu:
|
|||||||
weight: 31
|
weight: 31
|
||||||
---
|
---
|
||||||
|
|
||||||
|
Page resources are available for [page bundles]({{< relref "/content-management/page-bundles" >}}) only,
|
||||||
|
i.e. a directory with either a `index.md`, or `_index.md` file at its root. Resources are only attached to
|
||||||
|
the lowest page they are bundled with, and simple which names does not contain `index.md` are not attached any resource.
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
ResourceType
|
ResourceType
|
||||||
|
Loading…
x
Reference in New Issue
Block a user