mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-23 21:53:09 +02:00
Merge commit '35dec7c96f7ee3eb17dd444f7067f0c776fb56ae'
This commit is contained in:
22
docs/content/en/methods/resource/Colors.md
Normal file
22
docs/content/en/methods/resource/Colors.md
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: Colors
|
||||
description: Applicable to images, returns a slice of the most dominant colors using a simple histogram method.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: '[]string'
|
||||
signatures: [RESOURCE.Colors]
|
||||
---
|
||||
|
||||
{{< new-in 0.104.0 >}}
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/a.jpg" }}
|
||||
{{ .Colors }} → [#bebebd #514947 #768a9a #647789 #90725e #a48974]
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
This method is fast, but if you also scale down your images, it would be good for performance to extract the colors from the scaled image.
|
||||
|
||||
{{% include "methods/resource/_common/global-page-remote-resources.md" %}}
|
61
docs/content/en/methods/resource/Content.md
Normal file
61
docs/content/en/methods/resource/Content.md
Normal file
@@ -0,0 +1,61 @@
|
||||
---
|
||||
title: Content
|
||||
description: Returns the content of the given resource.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: any
|
||||
signatures: [RESOURCE.Content]
|
||||
toc:
|
||||
---
|
||||
|
||||
The `Content` method on a `Resource` object returns `template.HTML` when the resource type is `page`, otherwise it returns a `string`.
|
||||
|
||||
[resource type]: /methods/resource/resourcetype
|
||||
|
||||
{{< code file=assets/quotations/kipling.txt >}}
|
||||
He travels the fastest who travels alone.
|
||||
{{< /code >}}
|
||||
|
||||
To get the content:
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "quotations/kipling.txt" }}
|
||||
{{ .Content }} → He travels the fastest who travels alone.
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
To get the size in bytes:
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "quotations/kipling.txt" }}
|
||||
{{ .Content | len }} → 42
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
To create an inline image:
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/a.jpg" }}
|
||||
<img src="data:{{ .MediaType.Type }};base64,{{ .Content | base64Encode }}">
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
To create inline CSS:
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "css/style.css" }}
|
||||
<style>{{ .Content | safeCSS }}</style>
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
To create inline JavaScript:
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "js/script.js" }}
|
||||
<script>{{ .Content | safeJS }}</script>
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
{{% include "methods/resource/_common/global-page-remote-resources.md" %}}
|
48
docs/content/en/methods/resource/Crop.md
Normal file
48
docs/content/en/methods/resource/Crop.md
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
title: Crop
|
||||
description: Applicable to images, returns an image resource cropped to the given dimensions without resizing.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/resource/Fit
|
||||
- methods/resource/Fill
|
||||
- methods/resource/Resize
|
||||
- methods/resource/Process
|
||||
- functions/images/Process
|
||||
returnType: images.ImageResource
|
||||
signatures: [RESOURCE.Crop SPEC]
|
||||
toc: true
|
||||
---
|
||||
|
||||
Crop an image to match the given dimensions without resizing. You must provide both width and height.
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/original.jpg" }}
|
||||
{{ with .Crop "200x200" }}
|
||||
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
{{% include "methods/resource/_common/global-page-remote-resources.md" %}}
|
||||
|
||||
{{% include "/methods/resource/_common/processing-spec.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/original.jpg" }}
|
||||
{{ with .Crop "200x200 topright webp q85 lanczos" }}
|
||||
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
{{< img
|
||||
src="images/examples/zion-national-park.jpg"
|
||||
alt="Zion National Park"
|
||||
filter="Process"
|
||||
filterArgs="crop 200x200 topright webp q85 lanczos"
|
||||
example=true
|
||||
>}}
|
53
docs/content/en/methods/resource/Data.md
Normal file
53
docs/content/en/methods/resource/Data.md
Normal file
@@ -0,0 +1,53 @@
|
||||
---
|
||||
title: Data
|
||||
description: Applicable to resources returned by the resources.GetRemote function, returns information from the HTTP response.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- functions/resources/GetRemote
|
||||
- methods/resource/Err
|
||||
returnType: map
|
||||
signatures: [RESOURCE.Data]
|
||||
---
|
||||
|
||||
The `Data` method on a resource returned by the [`resources.GetRemote`] function returns information from the HTTP response.
|
||||
|
||||
[`resources.GetRemote`]: functions/resources/getremote
|
||||
|
||||
```go-html-template
|
||||
{{ $url := "https://example.org/images/a.jpg" }}
|
||||
{{ with resources.GetRemote $url }}
|
||||
{{ with .Err }}
|
||||
{{ errorf "%s" . }}
|
||||
{{ else }}
|
||||
{{ with .Data }}
|
||||
{{ .ContentLength }} → 42764
|
||||
{{ .ContentType }} → image/jpeg
|
||||
{{ .Status }} → 200 OK
|
||||
{{ .StatusCode }} → 200
|
||||
{{ .TransferEncoding }} → []
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ errorf "Unable to get remote resource %q" $url }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
ContentLength
|
||||
: (`int`) The content length in bytes.
|
||||
|
||||
ContentType
|
||||
: (`string`) The content type.
|
||||
|
||||
Status
|
||||
: (`string`) The HTTP status text.
|
||||
|
||||
StatusCode
|
||||
: (`int`) The HTTP status code.
|
||||
|
||||
TransferEncoding
|
||||
: (`string`) The transfer encoding.
|
||||
|
||||
|
||||
[`resources.GetRemote`]: functions/resources/getremote
|
56
docs/content/en/methods/resource/Err.md
Normal file
56
docs/content/en/methods/resource/Err.md
Normal file
@@ -0,0 +1,56 @@
|
||||
---
|
||||
title: Err
|
||||
description: Applicable to resources returned by the resources.GetRemote function, returns an error message if the HTTP request fails, else nil.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- functions/resources/GetRemote
|
||||
- methods/resource/Data
|
||||
returnType: resource.resourceError
|
||||
signatures: [RESOURCE.Err]
|
||||
---
|
||||
|
||||
The `Err` method on a resource returned by the [`resources.GetRemote`] function returns an error message if the HTTP request fails, else nil. If you do not handle the error yourself, Hugo will fail the build.
|
||||
|
||||
[`resources.GetRemote`]: functions/resources/getremote
|
||||
|
||||
In this example we send an HTTP request to a nonexistent domain:
|
||||
|
||||
```go-html-template
|
||||
{{ $url := "https://broken-example.org/images/a.jpg" }}
|
||||
{{ with resources.GetRemote $url }}
|
||||
{{ with .Err }}
|
||||
{{ errorf "%s" . }}
|
||||
{{ else }}
|
||||
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ errorf "Unable to get remote resource %q" $url }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
The code above captures the error from the HTTP request, then fails the build:
|
||||
|
||||
```text
|
||||
ERROR error calling resources.GetRemote: Get "https://broken-example.org/images/a.jpg": dial tcp: lookup broken-example.org on 127.0.0.53:53: no such host
|
||||
```
|
||||
|
||||
To log an error as a warning instead of an error:
|
||||
|
||||
```go-html-template
|
||||
{{ $url := "https://broken-example.org/images/a.jpg" }}
|
||||
{{ with resources.GetRemote $url }}
|
||||
{{ with .Err }}
|
||||
{{ warnf "%s" . }}
|
||||
{{ else }}
|
||||
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ errorf "Unable to get remote resource %q" $url }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
An HTTP response with a 404 status code is not an HTTP request error. To handle 404 status codes, code defensively using the nested `with-else-end` construct as shown above.
|
||||
{{% /note %}}
|
78
docs/content/en/methods/resource/Exif.md
Normal file
78
docs/content/en/methods/resource/Exif.md
Normal file
@@ -0,0 +1,78 @@
|
||||
---
|
||||
title: Exif
|
||||
description: Applicable to images, returns an EXIF object containing image metadata.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: exif.ExifInfo
|
||||
signatures: [RESOURCE.Exif]
|
||||
toc: true
|
||||
---
|
||||
|
||||
Applicable to images, the `Exif` method on an image `Resource` object returns an [EXIF] object containing image metadata.
|
||||
|
||||
## Methods
|
||||
|
||||
Date
|
||||
: (`time.Time`) Returns the image creation date/time. Format with the [`time.Format`]function.
|
||||
|
||||
Lat
|
||||
: (`float64`) Returns the GPS latitude in degrees.
|
||||
|
||||
Long
|
||||
: (`float64`) Returns the GPS longitude in degrees.
|
||||
|
||||
Tags
|
||||
: (`exif.Tags`) Returns a collection of the available EXIF tags for this image. You may include or exclude specific tags from this collection in the [site configuration].
|
||||
|
||||
## Examples
|
||||
|
||||
To list the creation date, location, and EXIF tags:
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/a.jpg" }}
|
||||
{{ with .Exif }}
|
||||
<p>Date: {{ .Date }}</p>
|
||||
<p>Lat/Long: {{ .Lat }}/{{ .Long }}</p>
|
||||
{{ with .Tags }}
|
||||
<p>Tags</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>Tag</th><th>Value</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{ range $k, $v := . }}
|
||||
<tr><td>{{ $k }}</td><td>{{ $v }}</td></tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
To list specific values:
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/a.jpg" }}
|
||||
{{ with .Exif }}
|
||||
<ul>
|
||||
{{ with .Date }}<li>Date: {{ .Format "January 02, 2006" }}</li>{{ end }}
|
||||
{{ with .Tags.ApertureValue }}<li>Aperture: {{ lang.FormatNumber 2 . }}</li>{{ end }}
|
||||
{{ with .Tags.BrightnessValue }}<li>Brightness: {{ lang.FormatNumber 2 . }}</li>{{ end }}
|
||||
{{ with .Tags.ExposureTime }}<li>Exposure Time: {{ . }}</li>{{ end }}
|
||||
{{ with .Tags.FNumber }}<li>F Number: {{ . }}</li>{{ end }}
|
||||
{{ with .Tags.FocalLength }}<li>Focal Length: {{ . }}</li>{{ end }}
|
||||
{{ with .Tags.ISOSpeedRatings }}<li>ISO Speed Ratings: {{ . }}</li>{{ end }}
|
||||
{{ with .Tags.LensModel }}<li>Lens Model: {{ . }}</li>{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
{{% include "methods/resource/_common/global-page-remote-resources.md" %}}
|
||||
|
||||
[exif]: https://en.wikipedia.org/wiki/Exif
|
||||
[site configuration]: /content-management/image-processing/#exif-data
|
||||
[`time.Format`]: /functions/time/format
|
48
docs/content/en/methods/resource/Fill.md
Normal file
48
docs/content/en/methods/resource/Fill.md
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
title: Fill
|
||||
description: Applicable to images, returns an image resource cropped and resized to the given dimensions.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/resource/Crop
|
||||
- methods/resource/Fit
|
||||
- methods/resource/Resize
|
||||
- methods/resource/Process
|
||||
- functions/images/Process
|
||||
returnType: images.ImageResource
|
||||
signatures: [RESOURCE.Fill SPEC]
|
||||
toc: true
|
||||
---
|
||||
|
||||
Crop and resize an image to match the given dimensions. You must provide both width and height.
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/original.jpg" }}
|
||||
{{ with .Fill "200x200" }}
|
||||
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
{{% include "methods/resource/_common/global-page-remote-resources.md" %}}
|
||||
|
||||
{{% include "/methods/resource/_common/processing-spec.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/original.jpg" }}
|
||||
{{ with .Fill "200x200 top webp q85 lanczos" }}
|
||||
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
{{< img
|
||||
src="images/examples/zion-national-park.jpg"
|
||||
alt="Zion National Park"
|
||||
filter="Process"
|
||||
filterArgs="fill 200x200 top webp q85 lanczos"
|
||||
example=true
|
||||
>}}
|
68
docs/content/en/methods/resource/Filter.md
Normal file
68
docs/content/en/methods/resource/Filter.md
Normal file
@@ -0,0 +1,68 @@
|
||||
---
|
||||
title: Filter
|
||||
description: Applicable to images, applies one or more image filters to the given image resource.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- functions/images/Filter
|
||||
returnType: resources.resourceAdapter
|
||||
signatures: [RESOURCE.Filter FILTER...]
|
||||
toc: true
|
||||
---
|
||||
|
||||
Apply one or more [image filters](#image-filters) to the given image.
|
||||
|
||||
To apply a single filter:
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/original.jpg" }}
|
||||
{{ with .Filter images.Grayscale }}
|
||||
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
To apply two or more filters, executing from left to right:
|
||||
|
||||
```go-html-template
|
||||
{{ $filters := slice
|
||||
images.Grayscale
|
||||
(images.GaussianBlur 8)
|
||||
}}
|
||||
{{ with resources.Get "images/original.jpg" }}
|
||||
{{ with .Filter $filters }}
|
||||
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
You can also apply image filters using the [`images.Filter`] function.
|
||||
|
||||
[`images.Filter`]: /functions/images/filter
|
||||
|
||||
{{% include "methods/resource/_common/global-page-remote-resources.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/original.jpg" }}
|
||||
{{ with .Filter images.Grayscale }}
|
||||
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
{{< img
|
||||
src="images/examples/zion-national-park.jpg"
|
||||
alt="Zion National Park"
|
||||
filter="Grayscale"
|
||||
filterArgs=""
|
||||
example=true
|
||||
>}}
|
||||
|
||||
## Image filters
|
||||
|
||||
Use any of these filters with the `Filter` method.
|
||||
|
||||
{{< list-pages-in-section path=/functions/images filter=functions_images_no_filters filterType=exclude >}}
|
48
docs/content/en/methods/resource/Fit.md
Normal file
48
docs/content/en/methods/resource/Fit.md
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
title: Fit
|
||||
description: Applicable to images, returns an image resource downscaled to fit the given dimensions while maintaining aspect ratio.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/resource/Crop
|
||||
- methods/resource/Fill
|
||||
- methods/resource/Resize
|
||||
- methods/resource/Process
|
||||
- functions/images/Process
|
||||
returnType: images.ImageResource
|
||||
signatures: [RESOURCE.Fit SPEC]
|
||||
toc: true
|
||||
---
|
||||
|
||||
Downscale an image to fit the given dimensions while maintaining aspect ratio. You must provide both width and height.
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/original.jpg" }}
|
||||
{{ with .Fit "200x200" }}
|
||||
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
{{% include "methods/resource/_common/global-page-remote-resources.md" %}}
|
||||
|
||||
{{% include "/methods/resource/_common/processing-spec.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/original.jpg" }}
|
||||
{{ with .Fit "300x175 webp q85 lanczos" }}
|
||||
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
{{< img
|
||||
src="images/examples/zion-national-park.jpg"
|
||||
alt="Zion National Park"
|
||||
filter="Process"
|
||||
filterArgs="fit 300x175 webp q85 lanczos"
|
||||
example=true
|
||||
>}}
|
27
docs/content/en/methods/resource/Height.md
Normal file
27
docs/content/en/methods/resource/Height.md
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
title: Height
|
||||
description: Applicable to images, returns the height of the given resource.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/resource/Width
|
||||
returnType: int
|
||||
signatures: [RESOURCE.Height]
|
||||
---
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/a.jpg" }}
|
||||
{{ .Height }} → 400
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
Use the `Width` and `Height` methods together when rendering an `img` element:
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/a.jpg" }}
|
||||
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}">
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
{{% include "methods/resource/_common/global-page-remote-resources.md" %}}
|
45
docs/content/en/methods/resource/Key.md
Normal file
45
docs/content/en/methods/resource/Key.md
Normal file
@@ -0,0 +1,45 @@
|
||||
---
|
||||
title: Key
|
||||
description: Returns the unique key for the given resource, equivalent to its publishing path.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/resource/Permalink
|
||||
- methods/resource/RelPermalink
|
||||
- methods/resource/Publish
|
||||
returnType: string
|
||||
signatures: [RESOURCE.Key]
|
||||
---
|
||||
|
||||
By way of example, consider this site configuration:
|
||||
|
||||
{{< code-toggle file=hugo >}}
|
||||
baseURL = 'https://example.org/docs/'
|
||||
{{< /code-toggle >}}
|
||||
|
||||
And this template:
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/a.jpg" }}
|
||||
{{ with resources.Copy "foo/bar/b.jpg" . }}
|
||||
{{ .Key }} → foo/bar/b.jpg
|
||||
|
||||
{{ .Name }} → images/a.jpg
|
||||
{{ .Title }} → images/a.jpg
|
||||
|
||||
{{ .RelPermalink }} → /docs/foo/bar/b.jpg
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
We used the [`resources.Copy`] function to change the publishing path. The `Key` method returns the updated path, but note that it is different than the value returned by [`RelPermalink`]. The `RelPermalink` value includes the subdirectory segment of the `baseURL` in the site configuration.
|
||||
|
||||
The `Key` method is useful if you need to get the resource's publishing path without publishing the resource. Unlike the `Permalink`, `RelPermalink`, or `Publish` methods, calling `Key` will not publish the resource.
|
||||
|
||||
|
||||
{{% include "methods/resource/_common/global-page-remote-resources.md" %}}
|
||||
|
||||
[`Permalink`]: /methods/resource/permalink
|
||||
[`RelPermalink`]: /methods/resource/relpermalink
|
||||
[`resources.Copy`]: /functions/resources/copy
|
52
docs/content/en/methods/resource/MediaType.md
Normal file
52
docs/content/en/methods/resource/MediaType.md
Normal file
@@ -0,0 +1,52 @@
|
||||
---
|
||||
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 resource’s media type.
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/a.jpg" }}
|
||||
{{ .MediaType.MainType }} → image
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
SubType
|
||||
: (`string`) The subtype of the resource’s 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 resource’s 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" %}}
|
82
docs/content/en/methods/resource/Name.md
Normal file
82
docs/content/en/methods/resource/Name.md
Normal file
@@ -0,0 +1,82 @@
|
||||
---
|
||||
title: Name
|
||||
description: Returns the name of the given resource as optionally defined in front matter, falling back to a relative path or hashed file name depending on resource type.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/resource/Title
|
||||
returnType: string
|
||||
signatures: [RESOURCE.Name]
|
||||
toc: true
|
||||
---
|
||||
|
||||
The value returned by the `Name` method on a `Resource` object depends on the resource type.
|
||||
|
||||
## Global resource
|
||||
|
||||
With a [global resource], the `Name` method returns the path to the resource, relative to the assets directory.
|
||||
|
||||
```text
|
||||
assets/
|
||||
└── images/
|
||||
└── a.jpg
|
||||
```
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/a.jpg" }}
|
||||
{{ .Name }} → images/a.jpg
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
## Page resource
|
||||
|
||||
With a [page resource], the `Name` method returns the path to the resource, relative to the page bundle.
|
||||
|
||||
```text
|
||||
content/
|
||||
├── posts/
|
||||
│ ├── post-1/
|
||||
│ │ ├── images/
|
||||
│ │ │ └── a.jpg
|
||||
│ │ └── index.md
|
||||
│ └── _index.md
|
||||
└── _index.md
|
||||
```
|
||||
|
||||
```go-html-template
|
||||
{{ with .Resources.Get "images/a.jpg" }}
|
||||
{{ .Name }} → images/a.jpg
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
If you create an element in the `resources` array in front matter, the `Name` method returns the value of the `name` parameter:
|
||||
|
||||
{{< code-toggle file=content/posts/post-1.md fm=true >}}
|
||||
title = 'Post 1'
|
||||
[[resources]]
|
||||
src = 'images/a.jpg'
|
||||
name = 'cat'
|
||||
title = 'Felix the cat'
|
||||
[resources.params]
|
||||
temperament = 'malicious'
|
||||
{{< /code-toggle >}}
|
||||
|
||||
```go-html-template
|
||||
{{ with .Resources.Get "cat" }}
|
||||
{{ .Name }} → cat
|
||||
{{ end }}
|
||||
```
|
||||
## Remote resource
|
||||
|
||||
With a [remote resource], the `Name` method returns a hashed file name.
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.GetRemote "https://example.org/images/a.jpg" }}
|
||||
{{ .Name }} → a_18432433023265451104.jpg
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
[global resource]: /getting-started/glossary/#global-resource
|
||||
[page resource]: /getting-started/glossary/#page-resource
|
||||
[remote resource]: /getting-started/glossary/#remote-resource
|
65
docs/content/en/methods/resource/Params.md
Normal file
65
docs/content/en/methods/resource/Params.md
Normal file
@@ -0,0 +1,65 @@
|
||||
---
|
||||
title: Params
|
||||
description: Returns a map of resource parameters as defined in front matter.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: map
|
||||
signatures: [RESOURCE.Params]
|
||||
---
|
||||
|
||||
Use the `Params` method with [page resources]. It is not applicable to either [global] or [remote] resources.
|
||||
|
||||
[global]: /getting-started/glossary/#global-resource
|
||||
[page resources]: /getting-started/glossary/#page-resource
|
||||
[remote]: /getting-started/glossary/#remote-resource
|
||||
|
||||
With this content structure:
|
||||
|
||||
```text
|
||||
content/
|
||||
├── posts/
|
||||
│ ├── cats/
|
||||
│ │ ├── images/
|
||||
│ │ │ └── a.jpg
|
||||
│ │ └── index.md
|
||||
│ └── _index.md
|
||||
└── _index.md
|
||||
```
|
||||
|
||||
And this front matter:
|
||||
|
||||
{{< code-toggle file=content/posts/cats.md fm=true >}}
|
||||
title = 'Cats'
|
||||
[[resources]]
|
||||
src = 'images/a.jpg'
|
||||
title = 'Felix the cat'
|
||||
[resources.params]
|
||||
alt = 'Photograph of black cat'
|
||||
temperament = 'vicious'
|
||||
{{< /code-toggle >}}
|
||||
|
||||
And this template:
|
||||
|
||||
```go-html-template
|
||||
{{ with .Resources.Get "images/a.jpg" }}
|
||||
<figure>
|
||||
<img alt="{{ .Params.alt }}" src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}">
|
||||
<figcaption>{{ .Title }} is {{ .Params.temperament }}</figcaption>
|
||||
</figure>
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
Hugo renders:
|
||||
|
||||
```html
|
||||
<figure>
|
||||
<img alt="Photograph of black cat" src="/posts/post-1/images/a.jpg" width="600" height="400">
|
||||
<figcaption>Felix the cat is vicious</figcaption>
|
||||
</figure>
|
||||
```
|
||||
|
||||
See the [page resources] section for more information.
|
||||
|
||||
[page resources]: /content-management/page-resources
|
25
docs/content/en/methods/resource/Permalink.md
Normal file
25
docs/content/en/methods/resource/Permalink.md
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
title: Permalink
|
||||
description: Publishes the given resource and returns its permalink.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/resource/RelPermalink
|
||||
- methods/resource/Publish
|
||||
- methods/resource/Key
|
||||
returnType: string
|
||||
signatures: [RESOURCE.Permalink]
|
||||
---
|
||||
|
||||
The `Permalink` method on a `Resource` object writes the resource to the publish directory, typically `public`, and returns its [permalink].
|
||||
|
||||
[permalink]: /getting-started/glossary/#permalink
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/a.jpg" }}
|
||||
{{ .Permalink }} → https://example.org/images/a.jpg
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
{{% include "methods/resource/_common/global-page-remote-resources.md" %}}
|
66
docs/content/en/methods/resource/Process.md
Normal file
66
docs/content/en/methods/resource/Process.md
Normal file
@@ -0,0 +1,66 @@
|
||||
---
|
||||
title: Process
|
||||
description: Applicable to images, returns an image resource processed with the given specification.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/resource/Crop
|
||||
- methods/resource/Fit
|
||||
- methods/resource/Fill
|
||||
- methods/resource/Resize
|
||||
- functions/images/Process
|
||||
returnType: images.ImageResource
|
||||
signatures: [RESOURCE.Process SPEC]
|
||||
toc: true
|
||||
---
|
||||
|
||||
Process an image with the given specification. The specification can contain an optional action, one of `crop`, `fill`, `fit`, or `resize`. This means that you can use this method instead of [`Crop`], [`Fill`], [`Fit`], or [`Resize`].
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/original.jpg" }}
|
||||
{{ with .Process "crop 200x200" }}
|
||||
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
You can also use this method to apply simple transformations such as rotation and conversion:
|
||||
|
||||
```go-html-template
|
||||
{{/* Rotate 90 degrees counter-clockwise. */}}
|
||||
{{ $image := $image.Process "r90" }}
|
||||
|
||||
{{/* Convert to WebP. */}}
|
||||
{{ $image := $image.Process "webp" }}
|
||||
```
|
||||
|
||||
The `Process` method is also available as a filter, which is more effective if you need to apply multiple filters to an image. See [`images.Process`].
|
||||
|
||||
{{% include "methods/resource/_common/global-page-remote-resources.md" %}}
|
||||
|
||||
{{% include "/methods/resource/_common/processing-spec.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/original.jpg" }}
|
||||
{{ with .Process "crop 200x200 topright webp q85 lanczos" }}
|
||||
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
{{< img
|
||||
src="images/examples/zion-national-park.jpg"
|
||||
alt="Zion National Park"
|
||||
filter="Process"
|
||||
filterArgs="crop 200x200 topright webp q85 lanczos"
|
||||
example=true
|
||||
>}}
|
||||
|
||||
[`Crop`]: /methods/resource/crop
|
||||
[`Fill`]: /methods/resource/fill
|
||||
[`Fit`]: /methods/resource/fit
|
||||
[`Resize`]: /methods/resource/resize
|
||||
[`images.Process`]: /functions/images/process
|
35
docs/content/en/methods/resource/Publish.md
Normal file
35
docs/content/en/methods/resource/Publish.md
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
title: Publish
|
||||
description: Publishes the given resource.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/resource/Permalink
|
||||
- methods/resource/RelPermalink
|
||||
- methods/resource/Key
|
||||
returnType: nil
|
||||
signatures: [RESOURCE.Publish]
|
||||
---
|
||||
|
||||
The `Publish` method on a `Resource` object writes the resource to the publish directory, typically `public`.
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/a.jpg" }}
|
||||
{{ .Publish }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
The `Permalink` and `RelPermalink` methods also publish a resource. `Publish` is a convenience method for publishing without a return value. For example, this:
|
||||
|
||||
```go-html-template
|
||||
{{ $resource.Publish }}
|
||||
```
|
||||
|
||||
Instead of this:
|
||||
|
||||
```go-html-template
|
||||
{{ $noop := $resource.Permalink }}
|
||||
```
|
||||
|
||||
{{% include "methods/resource/_common/global-page-remote-resources.md" %}}
|
25
docs/content/en/methods/resource/RelPermalink.md
Normal file
25
docs/content/en/methods/resource/RelPermalink.md
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
title: RelPermalink
|
||||
description: Publishes the given resource and returns its relative permalink.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/resource/Permalink
|
||||
- methods/resource/Publish
|
||||
- methods/resource/Key
|
||||
returnType: string
|
||||
signatures: [RESOURCE.RelPermalink]
|
||||
---
|
||||
|
||||
The `Permalink` method on a `Resource` object writes the resource to the publish directory, typically `public`, and returns its [relative permalink].
|
||||
|
||||
[relative permalink]: /getting-started/glossary/#relative-permalink
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/a.jpg" }}
|
||||
{{ .RelPermalink }} → /images/a.jpg
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
{{% include "methods/resource/_common/global-page-remote-resources.md" %}}
|
49
docs/content/en/methods/resource/Resize.md
Normal file
49
docs/content/en/methods/resource/Resize.md
Normal file
@@ -0,0 +1,49 @@
|
||||
---
|
||||
title: Resize
|
||||
description: Applicable to images, returns an image resource resized to the given width and/or height.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/resource/Crop
|
||||
- methods/resource/Fit
|
||||
- methods/resource/Fill
|
||||
- methods/resource/Process
|
||||
- functions/images/Process
|
||||
returnType: images.ImageResource
|
||||
signatures: [RESOURCE.Resize SPEC]
|
||||
---
|
||||
|
||||
Resize an image to the given width and/or height.
|
||||
|
||||
If you specify both width and height, the resulting image will be disproportionally scaled unless the original image has the same aspect ratio.
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/original.jpg" }}
|
||||
{{ with .Resize "300x" }}
|
||||
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
{{% include "methods/resource/_common/global-page-remote-resources.md" %}}
|
||||
|
||||
{{% include "/methods/resource/_common/processing-spec.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/original.jpg" }}
|
||||
{{ with .Resize "300x webp q85 lanczos" }}
|
||||
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
{{< img
|
||||
src="images/examples/zion-national-park.jpg"
|
||||
alt="Zion National Park"
|
||||
filter="Process"
|
||||
filterArgs="resize 300x webp q85 lanczos"
|
||||
example=true
|
||||
>}}
|
43
docs/content/en/methods/resource/ResourceType.md
Normal file
43
docs/content/en/methods/resource/ResourceType.md
Normal file
@@ -0,0 +1,43 @@
|
||||
---
|
||||
title: ResourceType
|
||||
description: Returns the main type of the given resource's media type.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: string
|
||||
signatures: [RESOURCE.ResourceType]
|
||||
---
|
||||
|
||||
Common resource types include `audio`, `image`, `text`, and `video`.
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "image/a.jpg" }}
|
||||
{{ .ResourceType }} → image
|
||||
{{ .MediaType.MainType }} → image
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
When working with content files, the resource type is `page`.
|
||||
|
||||
```text
|
||||
content/
|
||||
├── lessons/
|
||||
│ ├── lesson-1/
|
||||
│ │ ├── _objectives.md <-- resource type = page
|
||||
│ │ ├── _topics.md <-- resource type = page
|
||||
│ │ ├── _example.jpg <-- resource type = image
|
||||
│ │ └── index.md
|
||||
│ └── _index.md
|
||||
└── _index.md
|
||||
```
|
||||
|
||||
With the structure above, we can range through page resources of type `page` to build content:
|
||||
|
||||
{{< code file=layouts/lessons/single.html >}}
|
||||
{{ range .Resources.ByType "page" }}
|
||||
{{ .Content }}
|
||||
{{ end }}
|
||||
{{< /code >}}
|
||||
|
||||
{{% include "methods/resource/_common/global-page-remote-resources.md" %}}
|
95
docs/content/en/methods/resource/Title.md
Normal file
95
docs/content/en/methods/resource/Title.md
Normal file
@@ -0,0 +1,95 @@
|
||||
---
|
||||
title: Title
|
||||
description: Returns the title of the given resource as optionally defined in front matter, falling back to a relative path or hashed file name depending on resource type.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/resource/Name
|
||||
returnType: string
|
||||
signatures: [RESOURCE.Title]
|
||||
toc: true
|
||||
---
|
||||
|
||||
The value returned by the `Title` method on a `Resource` object depends on the resource type.
|
||||
|
||||
## Global resource
|
||||
|
||||
With a [global resource], the `Title` method returns the path to the resource, relative to the assets directory.
|
||||
|
||||
```text
|
||||
assets/
|
||||
└── images/
|
||||
└── a.jpg
|
||||
```
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/a.jpg" }}
|
||||
{{ .Title }} → images/a.jpg
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
## Page resource
|
||||
|
||||
With a [page resource], the `Title` method returns the path to the resource, relative to the page bundle.
|
||||
|
||||
```text
|
||||
content/
|
||||
├── posts/
|
||||
│ ├── post-1/
|
||||
│ │ ├── images/
|
||||
│ │ │ └── a.jpg
|
||||
│ │ └── index.md
|
||||
│ └── _index.md
|
||||
└── _index.md
|
||||
```
|
||||
|
||||
```go-html-template
|
||||
{{ with .Resources.Get "images/a.jpg" }}
|
||||
{{ .Title }} → images/a.jpg
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
If you create an element in the `resources` array in front matter, the `Title` method returns the value of the `title` parameter:
|
||||
|
||||
{{< code-toggle file=content/posts/post-1.md fm=true >}}
|
||||
title = 'Post 1'
|
||||
[[resources]]
|
||||
src = 'images/a.jpg'
|
||||
name = 'cat'
|
||||
title = 'Felix the cat'
|
||||
[resources.params]
|
||||
temperament = 'malicious'
|
||||
{{< /code-toggle >}}
|
||||
|
||||
```go-html-template
|
||||
{{ with .Resources.Get "cat" }}
|
||||
{{ .Title }} → Felix the cat
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
If the page resource is a content file, the `Title` methods return the `title` field as defined in front matter.
|
||||
|
||||
```text
|
||||
content/
|
||||
├── lessons/
|
||||
│ ├── lesson-1/
|
||||
│ │ ├── _objectives.md <-- resource type = page
|
||||
│ │ └── index.md
|
||||
│ └── _index.md
|
||||
└── _index.md
|
||||
```
|
||||
|
||||
## Remote resource
|
||||
|
||||
With a [remote resource], the `Title` method returns a hashed file name.
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.GetRemote "https://example.org/images/a.jpg" }}
|
||||
{{ .Title }} → a_18432433023265451104.jpg
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
[global resource]: /getting-started/glossary/#global-resource
|
||||
[page resource]: /getting-started/glossary/#page-resource
|
||||
[remote resource]: /getting-started/glossary/#remote-resource
|
27
docs/content/en/methods/resource/Width.md
Normal file
27
docs/content/en/methods/resource/Width.md
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
title: Width
|
||||
description: Applicable to images, returns the width of the given resource.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/resource/Height
|
||||
returnType: int
|
||||
signatures: [RESOURCE.Width]
|
||||
---
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/a.jpg" }}
|
||||
{{ .Width }} → 600
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
Use the `Width` and `Height` methods together when rendering an `img` element:
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/a.jpg" }}
|
||||
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}">
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
{{% include "methods/resource/_common/global-page-remote-resources.md" %}}
|
13
docs/content/en/methods/resource/_common/_index.md
Normal file
13
docs/content/en/methods/resource/_common/_index.md
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
cascade:
|
||||
_build:
|
||||
list: never
|
||||
publishResources: false
|
||||
render: never
|
||||
---
|
||||
|
||||
<!--
|
||||
Files within this headless branch bundle are markdown snippets. Each file must contain front matter delimiters, though front matter fields are not required.
|
||||
|
||||
Include the rendered content using the "include" shortcode.
|
||||
-->
|
@@ -0,0 +1,13 @@
|
||||
---
|
||||
# Do not remove front matter.
|
||||
---
|
||||
|
||||
{{% note %}}
|
||||
|
||||
Use this method with [global], [page], or [remote] resources.
|
||||
|
||||
[global]: /getting-started/glossary/#global-resource
|
||||
[page]: /getting-started/glossary/#page-resource
|
||||
[remote]: /getting-started/glossary/#remote-resource
|
||||
|
||||
{{% /note %}}
|
36
docs/content/en/methods/resource/_common/processing-spec.md
Normal file
36
docs/content/en/methods/resource/_common/processing-spec.md
Normal file
@@ -0,0 +1,36 @@
|
||||
---
|
||||
# Do not remove front matter.
|
||||
---
|
||||
|
||||
## Process specification
|
||||
|
||||
The process specification is a space-delimited, case-insensitive list of one or more of the following in any sequence:
|
||||
|
||||
action
|
||||
: Applicable to the [`Process`](/methods/resource/process) method only. Specify zero or one of `crop`, `fill`, `fit`, or `resize`. If you specify an action you must also provide dimensions.
|
||||
|
||||
dimensions
|
||||
: Provide width _or_ height when using the [`Resize`](/methods/resource/resize) method, else provide both width _and_ height. See [details](/content-management/image-processing/#dimensions).
|
||||
|
||||
anchor
|
||||
: Use with the [`Crop`](/methods/resource/crop) and [`Fill`](/methods/resource/fill) methods. Specify zero or one of `TopLeft`, `Top`, `TopRight`, `Left`, `Center`, `Right`, `BottomLeft`, `Bottom`, `BottomRight`, or `Smart`. Default is `Smart`. See [details](/content-management/image-processing/#anchor).
|
||||
|
||||
rotation
|
||||
: Typically specify zero or one of `r90`, `r180`, or `r270`. Also supports arbitrary rotation angles. See [details](/content-management/image-processing/#rotation).
|
||||
|
||||
target format
|
||||
: Specify zero or one of `gif`, `jpeg`, `png`, `tiff`, or `webp`. See [details](/content-management/image-processing/#target-format).
|
||||
|
||||
quality
|
||||
: Applicable to JPEG and WebP images. Optionally specify `qN` where `N` is an integer in the range [0, 100]. Default is `75`. See [details](/content-management/image-processing/#quality).
|
||||
|
||||
hint
|
||||
: Applicable to WebP images and equivalent to the `-preset` flag for the [`cwebp`] encoder. Specify zero or one of `drawing`, `icon`, `photo`, `picture`, or `text`. Default is `photo`. See [details](/content-management/image-processing/#hint).
|
||||
|
||||
[`cwebp`]: https://developers.google.com/speed/webp/docs/cwebp
|
||||
|
||||
background color
|
||||
: When converting a PNG or WebP with transparency to a format that does not support transparency, optionally specify a background color using a 3-digit or a 6-digit hexadecimal color code. Default is `#ffffff` (white). See [details](/content-management/image-processing/#background-color).
|
||||
|
||||
resampling filter
|
||||
: Typically specify zero or one of `Box`, `Lanczos`, `CatmullRom`, `MitchellNetravali`, `Linear`, or `NearestNeighbor`. Other resampling filters are available. See [details](/content-management/image-processing/#resampling-filter).
|
12
docs/content/en/methods/resource/_index.md
Normal file
12
docs/content/en/methods/resource/_index.md
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
title: Resource methods
|
||||
linkTitle: Resource
|
||||
description: Use these methods with global, page, and remote Resource objects.
|
||||
categories: []
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
parent: methods
|
||||
---
|
||||
|
||||
Use these methods with global, page, and remote Resource objects.
|
Reference in New Issue
Block a user