Skip to content

Commit bde471d

Browse files
committed
Remove alt text requirement from img shortcode
1 parent 2474fb5 commit bde471d

File tree

1 file changed

+26
-35
lines changed

1 file changed

+26
-35
lines changed

layouts/shortcodes/img.html

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,29 @@
1-
<!--
2-
Image template - Renders a full html figure.
3-
Everything could be set with named variables.
4-
Only src and alt are required.
5-
-->
6-
{{ if .Get "alt" }}
7-
<figure{{ with .Get "class" }} class="{{ . }}"{{ end }}>
8-
{{- if .Get "link" -}}
9-
<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
1+
<figure{{ with .Get "class" }} class="{{ . }}"{{ end }}>
2+
{{- if .Get "link" -}}
3+
<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
4+
{{- end -}}
5+
<img src="{{ .Get "src" | relURL }}"
6+
{{- if or (.Get "alt") (.Get "caption") }}
7+
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
108
{{- end -}}
11-
<img src="{{ .Get "src" | relURL }}"
12-
{{- if or (.Get "alt") (.Get "caption") }}
13-
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
9+
{{- with .Get "width" }} width="{{ . }}"{{ end -}}
10+
{{- with .Get "height" }} height="{{ . }}"{{ end -}}
11+
{{- with .Get "loading" }} loading="{{ . }}"{{ end -}}
12+
/><!-- Closing img tag -->
13+
{{- if .Get "link" }}</a>{{ end -}}
14+
{{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") -}}
15+
<figcaption>
16+
{{ with (.Get "title") -}}
17+
<h4>{{ . }}</h4>
1418
{{- end -}}
15-
{{- with .Get "width" }} width="{{ . }}"{{ end -}}
16-
{{- with .Get "height" }} height="{{ . }}"{{ end -}}
17-
{{- with .Get "loading" }} loading="{{ . }}"{{ end -}}
18-
/><!-- Closing img tag -->
19-
{{- if .Get "link" }}</a>{{ end -}}
20-
{{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") -}}
21-
<figcaption>
22-
{{ with (.Get "title") -}}
23-
<h4>{{ . }}</h4>
19+
{{- if or (.Get "caption") (.Get "attr") -}}<p>
20+
{{- .Get "caption" | markdownify -}}
21+
{{- with .Get "attrlink" }}
22+
<a href="{{ . }}">
2423
{{- end -}}
25-
{{- if or (.Get "caption") (.Get "attr") -}}<p>
26-
{{- .Get "caption" | markdownify -}}
27-
{{- with .Get "attrlink" }}
28-
<a href="{{ . }}">
29-
{{- end -}}
30-
{{- .Get "attr" | markdownify -}}
31-
{{- if .Get "attrlink" }}</a>{{ end }}</p>
32-
{{- end }}
33-
</figcaption>
34-
{{- end }}
35-
</figure>
36-
{{ else }}
37-
{{ print "Alt text missing!" }}
38-
{{ end }}
24+
{{- .Get "attr" | markdownify -}}
25+
{{- if .Get "attrlink" }}</a>{{ end }}</p>
26+
{{- end }}
27+
</figcaption>
28+
{{- end }}
29+
</figure>

0 commit comments

Comments
 (0)