Add alt text support to figures/image shortcode

This commit is contained in:
Eryn Wells 2023-02-01 09:10:35 -08:00
parent 5deda1c5ee
commit 6affc7b454

View file

@ -1,8 +1,9 @@
{{ $img := (.Page.Resources.GetMatch (.Get "name")) }} {{- $img := (.Page.Resources.GetMatch (.Get "name")) -}}
{{ $resized_img := $img.Fit "1280x1280" }} {{- $resized_img := $img.Fit "1280x1280" -}}
{{- $altText := $img.Params.alt | default $img.Title -}}
<figure> <figure>
<a href="{{ $img.RelPermalink }}"> <a href="{{ $img.RelPermalink }}">
<img src="{{ $resized_img.RelPermalink }}"> <img src="{{ $resized_img.RelPermalink }}"{{ with $altText}} alt="{{ . }}"{{ end }}>
</a> </a>
{{ if $img.Title }} {{ if $img.Title }}
<figcaption>{{ $img.Title }}</figcaption> <figcaption>{{ $img.Title }}</figcaption>