Skip to content

Commit bb733c5

Browse files
johanrinclaude
andcommitted
Use semantic figure/figcaption for images with titles
Wraps images that have a title attribute in <figure> with <figcaption> for better accessibility and SEO. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent ad2bdfb commit bb733c5

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

layouts/_default/_markup/render-image.html

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,29 @@
22
{{- if and (ne .Page.Kind "section") (.Page.Section ) }}
33
<!-- Generate a unique id for each image -->
44
{{- $random := (substr (md5 .Destination) 0 5) }}
5+
{{- if .Title }}
6+
<figure>
7+
<input type="checkbox" id="zoomCheck-{{$random}}" hidden>
8+
<label for="zoomCheck-{{$random}}">
9+
<img class="zoomCheck" loading="lazy" decoding="async"
10+
src="{{ .Destination | safeURL }}" alt="{{ .Text }}" />
11+
</label>
12+
<figcaption>{{ .Title }}</figcaption>
13+
</figure>
14+
{{- else }}
515
<input type="checkbox" id="zoomCheck-{{$random}}" hidden>
616
<label for="zoomCheck-{{$random}}">
7-
<img class="zoomCheck" loading="lazy" decoding="async"
8-
src="{{ .Destination | safeURL }}" alt="{{ .Text }}"
9-
{{ with.Title}} title="{{ . }}" {{ end }} />
17+
<img class="zoomCheck" loading="lazy" decoding="async"
18+
src="{{ .Destination | safeURL }}" alt="{{ .Text }}" />
1019
</label>
20+
{{- end }}
1121
{{- else }}
12-
<img loading="lazy" decoding="async" src="{{ .Destination | safeURL }}"
13-
alt="{{ .Text }}" {{ with .Title}} title="{{ . }}" {{ end }} />
22+
{{- if .Title }}
23+
<figure>
24+
<img loading="lazy" decoding="async" src="{{ .Destination | safeURL }}" alt="{{ .Text }}" />
25+
<figcaption>{{ .Title }}</figcaption>
26+
</figure>
27+
{{- else }}
28+
<img loading="lazy" decoding="async" src="{{ .Destination | safeURL }}" alt="{{ .Text }}" />
29+
{{- end }}
1430
{{- end }}

0 commit comments

Comments
 (0)