From a353c4a549716317ee7cbb4896f57920aac68d16 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Mon, 20 Nov 2023 11:55:58 -0800 Subject: [PATCH] {{< img >}} shortcode --- layouts/shortcodes/img.html | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 layouts/shortcodes/img.html diff --git a/layouts/shortcodes/img.html b/layouts/shortcodes/img.html new file mode 100644 index 0000000..5016146 --- /dev/null +++ b/layouts/shortcodes/img.html @@ -0,0 +1,21 @@ +{{ $img := dict }} +{{ with .Get "name" }} + {{ $img = $.Page.Resources.GetMatch . }} +{{ else }} + {{ errorf "No name given to img shortcode" }} +{{ end }} + +{{/* Space separated list of classes to apply to the tag */}} +{{ $classes := .Get "class" }} + +{{ $altText := $img.Params.alt | default (.Get "alt") }} +{{ if not $altText }} + {{ warnf "Image doesn't have alt text. %s" $img.Permalink }} +{{ end }} + +{{ $resizedImg := $img.Fit "1280x1280" }} +{{ $altText }}