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")) }}
{{ $resized_img := $img.Fit "1280x1280" }}
{{- $img := (.Page.Resources.GetMatch (.Get "name")) -}}
{{- $resized_img := $img.Fit "1280x1280" -}}
{{- $altText := $img.Params.alt | default $img.Title -}}
<figure>
<a href="{{ $img.RelPermalink }}">
<img src="{{ $resized_img.RelPermalink }}">
<img src="{{ $resized_img.RelPermalink }}"{{ with $altText}} alt="{{ . }}"{{ end }}>
</a>
{{ if $img.Title }}
<figcaption>{{ $img.Title }}</figcaption>