mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-23 21:53:09 +02:00
Merge commit 'a024bc7d76fcc5e49e8210f9b0896db9ef21861a'
This commit is contained in:
@@ -13,7 +13,7 @@ action:
|
||||
toc: true
|
||||
---
|
||||
|
||||
{{< new-in 0.121.2 >}}
|
||||
{{< new-in 0.121.2 />}}
|
||||
|
||||
## Usage
|
||||
|
||||
|
@@ -15,7 +15,7 @@ action:
|
||||
toc: true
|
||||
---
|
||||
|
||||
{{< new-in 0.123.0 >}}
|
||||
{{< new-in 0.123.0 />}}
|
||||
|
||||
## Options
|
||||
|
||||
|
@@ -13,7 +13,7 @@ action:
|
||||
toc: true
|
||||
---
|
||||
|
||||
{{< new-in 0.141.0 >}}
|
||||
{{< new-in 0.141.0 />}}
|
||||
|
||||
The `images.Mask` filter applies a mask to an image. Black pixels in the mask make the corresponding areas of the base image transparent, while white pixels keep them opaque. Color images are converted to grayscale for masking purposes. The mask is automatically resized to match the dimensions of the base image.
|
||||
|
||||
|
@@ -13,7 +13,7 @@ action:
|
||||
toc: true
|
||||
---
|
||||
|
||||
{{< new-in 0.119.0 >}}
|
||||
{{< new-in 0.119.0 />}}
|
||||
|
||||
The opacity value must be in the range [0, 1]. A value of `0` produces a transparent image, and a value of `1` produces an opaque image (no transparency).
|
||||
|
||||
|
@@ -13,7 +13,7 @@ action:
|
||||
toc: true
|
||||
---
|
||||
|
||||
{{< new-in 0.120.0 >}}
|
||||
{{< new-in 0.120.0 />}}
|
||||
|
||||
The last argument is the canvas color, expressed as an RGB or RGBA [hexadecimal color]. The default value is `ffffffff` (opaque white). The preceding arguments are the padding values, in pixels, using the CSS [shorthand property] syntax. Negative padding values will crop the image.
|
||||
|
||||
|
@@ -14,7 +14,7 @@ action:
|
||||
toc: true
|
||||
---
|
||||
|
||||
{{< new-in 0.119.0 >}}
|
||||
{{< new-in 0.119.0 />}}
|
||||
|
||||
This filter has the same options as the [`Process`] method on a `Resource` object, but using it as a filter may be more effective if you need to apply multiple filters to an image.
|
||||
|
||||
|
@@ -6,12 +6,12 @@ action:
|
||||
aliases: []
|
||||
related: []
|
||||
returnType: images.ImageResource
|
||||
signatures: ['images.QR TEXT OPTIONS']
|
||||
signatures: ['images.QR TEXT [OPTIONS]']
|
||||
toc: true
|
||||
math: true
|
||||
---
|
||||
|
||||
{{< new-in 0.141.0 >}}
|
||||
{{< new-in 0.141.0 />}}
|
||||
|
||||
The `images.QR` function encodes the given text into a [QR code] using the specified options, returning an image resource. The size of the generated image depends on three factors:
|
||||
|
||||
@@ -54,7 +54,7 @@ To create a QR code using the default values for `level` and `scale`:
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
{{< qr text="https://gohugo.io" class="qrcode" />}}
|
||||
{{< qr text="https://gohugo.io" class="qrcode" targetDir="images/qr" />}}
|
||||
|
||||
Specify `level`, `scale`, and `targetDir` as needed to achieve the desired result:
|
||||
|
||||
@@ -63,14 +63,45 @@ Specify `level`, `scale`, and `targetDir` as needed to achieve the desired resul
|
||||
{{ $opts := dict
|
||||
"level" "high"
|
||||
"scale" 3
|
||||
"targetDir" "codes"
|
||||
"targetDir" "images/qr"
|
||||
}}
|
||||
{{ with images.QR $text $opts }}
|
||||
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
{{< qr text="https://gohugo.io" level="high" scale=3 targetDir="codes" class="qrcode" />}}
|
||||
{{< qr text="https://gohugo.io" level="high" scale=3 targetDir="codes" class="qrcode" targetDir="images/qr" />}}
|
||||
|
||||
To include a QR code that points to the `Permalink` of the current page:
|
||||
|
||||
{{< code file=layouts/_default/single.html >}}
|
||||
{{ with images.QR .Permalink }}
|
||||
<img
|
||||
src="{{ .RelPermalink }}"
|
||||
width="{{ .Width }}"
|
||||
height="{{ .Height }}"
|
||||
alt="QR code linking to {{ $.Permalink }}"
|
||||
class="qr-code"
|
||||
loading="lazy"
|
||||
>
|
||||
{{ end }}
|
||||
{{< /code >}}
|
||||
|
||||
Then hide the QR code with CSS unless printing the page:
|
||||
|
||||
```css
|
||||
/* Hide QR code by default */
|
||||
.qr-code {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Show QR code when printing */
|
||||
@media print {
|
||||
.qr-code {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Scale
|
||||
|
||||
|
@@ -18,7 +18,7 @@ toc: true
|
||||
Although none of the options are required, at a minimum you will want to set the `size` to be some reasonable percentage of the image height.
|
||||
|
||||
alignx
|
||||
{{< new-in 0.141.0 >}}
|
||||
{{< new-in 0.141.0 />}}
|
||||
: (`string`) The horizontal alignment of the text relative to the horizontal offset, one of `left`, `center`, or `right`. Default is `left`.
|
||||
|
||||
color
|
||||
|
Reference in New Issue
Block a user