From 980d0a43d4bfa652899cd3fb120229b68a814263 Mon Sep 17 00:00:00 2001 From: Luca Beltrame Date: Tue, 5 Jan 2021 17:34:53 +0100 Subject: [PATCH] Shortcode to generate image thumbnails --- layouts/shortcodes/imgthumb.html | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 layouts/shortcodes/imgthumb.html diff --git a/layouts/shortcodes/imgthumb.html b/layouts/shortcodes/imgthumb.html new file mode 100644 index 0000000..40aedee --- /dev/null +++ b/layouts/shortcodes/imgthumb.html @@ -0,0 +1,40 @@ +{{ $image := resources.GetMatch (.Get "src") }} +{{ $size := .Get "size" }} +{{/* Set the right options for Resize */}} +{{ $options := printf "%s %s %s" $size "jpg q90" "Box"}} +{{ $imagethumbnail := $image.Resize $options }} + + + + {{ with .Get + + {{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") -}} +
+ {{ with (.Get "title") -}} +

{{ . }}

+ {{- end -}} + {{- if or (.Get "caption") (.Get "attr") -}}

+ {{- .Get "caption" | markdownify -}} + {{- with .Get "attrlink" }} + + {{- end -}} + {{- .Get "attr" | markdownify -}} + {{- if .Get "attrlink" }}{{ end }}

+ {{- end }} +
+ {{- end }} + + + {{ with .Get + +