diff options
author | Timmy Keller <tjk@tjkeller.xyz> | 2024-08-10 21:03:16 -0500 |
---|---|---|
committer | Timmy Keller <tjk@tjkeller.xyz> | 2024-08-10 21:03:16 -0500 |
commit | f49d28caa3005c608eec9f8f82b1d9625ae37c01 (patch) | |
tree | 3538601cd4ac385e70517f6732290b09c806f936 /layouts/shortcodes/img.html | |
download | hugo-theme-tjkbasic-f49d28caa3005c608eec9f8f82b1d9625ae37c01.tar.xz hugo-theme-tjkbasic-f49d28caa3005c608eec9f8f82b1d9625ae37c01.zip |
initial commit
Diffstat (limited to 'layouts/shortcodes/img.html')
-rw-r--r-- | layouts/shortcodes/img.html | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/layouts/shortcodes/img.html b/layouts/shortcodes/img.html new file mode 100644 index 0000000..65ca44f --- /dev/null +++ b/layouts/shortcodes/img.html @@ -0,0 +1,34 @@ +<!-- https://gohugo.io/content-management/image-processing/ --> + +<!-- Get image --> +{{ $image := resources.GetMatch (.Get "src") }} + +<!-- Get parameters --> +{{ $alt := .Get "alt" | default "" }} +{{ $rotation := .Get "rotation" | default 0 }} + +<!-- Get quality --> +{{ $quality := .Get "quality" | default "original" }} + +{{ $q := 0 }} +{{ $size := 0 }} +{{ if eq $quality "low" }} + {{ $q = 60 }} + {{ $size = 600 }} +{{ else if eq $quality "medium" }} + {{ $q = 75 }} + {{ $size = 1000 }} +{{ else if eq $quality "high" }} + {{ $q = 90 }} + {{ $size = 1200 }} +{{ end }} + + +<!-- Make image --> +{{ if ne $quality "original" }} + {{ $image = $image.Resize (printf "%dx q%d r%d" $size $q $rotation) }} +{{ end }} +<figure> + <img src="{{ $image.RelPermalink }}" title="{{ $alt }}" alt="{{ $alt }}" /> + <figcaption>{{ $alt }}</figcaption> +</figure> |