From cbaa641826ed30420b3bb9f97c9b26d7fe1c6477 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Thu, 7 Feb 2019 16:25:14 +0100 Subject: [PATCH] add alt tag to image shortcode --- layouts/shortcodes/imgproc.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/layouts/shortcodes/imgproc.html b/layouts/shortcodes/imgproc.html index 2e167d8..5ebdccd 100644 --- a/layouts/shortcodes/imgproc.html +++ b/layouts/shortcodes/imgproc.html @@ -1,6 +1,7 @@ {{ $original := .Page.Resources.GetMatch (printf "*%s*" (.Get 0)) }} {{ $command := strings.ToLower (printf "%s" (.Get 1)) }} {{ $options := .Get 2 }} +{{ $customAlt := .Get 3 }} {{ if eq $command "fit"}} {{ .Scratch.Set "image" ($original.Fit $options) }} {{ else if eq $command "resize"}} @@ -11,9 +12,13 @@ {{ errorf "Invalid image processing command: Must be one of Fit, Fill or Resize. Is: %s" ($command)}} {{ end }} {{ $image := .Scratch.Get "image" }} +{{ $imgAlt := $original.Title }} +{{ if $customAlt }} +{{ $imgAlt = $customAlt }} +{{ end }}
- + {{ $imgAlt }}