tpl/images: Change signature of images.QR to images.QR TEXT OPTIONS

Closes #13230
This commit is contained in:
Joe Mooring 2025-01-08 10:10:18 -08:00 committed by Bjørn Erik Pedersen
parent d9594a96fc
commit b13d0a68e6
5 changed files with 42 additions and 35 deletions

View file

@ -6,7 +6,7 @@ action:
aliases: []
related: []
returnType: images.ImageResource
signatures: ['images.QR OPTIONS']
signatures: ['images.QR TEXT OPTIONS']
toc: true
math: true
---
@ -25,9 +25,6 @@ Although the default option values are sufficient for most applications, you sho
## Options
text
: (`string`) The text to encode.
level
: (`string`) The error correction level to use when encoding the text, one of `low`, `medium`, `quartile`, or `high`. Default is `medium`.
@ -51,8 +48,8 @@ targetDir
To create a QR code using the default values for `level` and `scale`:
```go-html-template
{{ $opts := dict "text" "https://gohugo.io" }}
{{ with images.QR $opts }}
{{ $text := "https://gohugo.io" }}
{{ with images.QR $text }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ end }}
```
@ -62,13 +59,13 @@ To create a QR code using the default values for `level` and `scale`:
Specify `level`, `scale`, and `targetDir` as needed to achieve the desired result:
```go-html-template
{{ $text := "https://gohugo.io" }}
{{ $opts := dict
"text" "https://gohugo.io"
"level" "high"
"scale" 3
"targetDir" "codes"
}}
{{ with images.QR $opts }}
{{ with images.QR $text $opts }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ end }}
```