1
Fork 0

Add alt attributes for content images

This commit is contained in:
Jake Howard 2018-05-18 19:19:04 +01:00
parent 13fd2f8659
commit e17520cfaa
Signed by: jake
GPG key ID: 57AFB45680EDD477
2 changed files with 13 additions and 5 deletions

View file

@ -1,10 +1,14 @@
{{ define "img" }}
<img src='{{ .Get "src" }}' class='{{ .Get "class" }}' alt="{{ .Inner | plainify }}" />
{{ end }}
{{ if .Inner }}
<figure>
<img src='{{ .Get "src" }}' class='{{ .Get "class" }}' />
{{ template "img" . }}
<figcaption>
<small>{{ .Inner }}</small>
</figcaption>
</figure>
{{ else }}
<img src='{{ .Get "src" }}' class='{{ .Get "class" }}' />
{{ template "img" . }}
{{ end }}

View file

@ -13,15 +13,19 @@
{{ .Scratch.Set "image" ($original.Fill $options) }}
{{ end }}
{{ $image := .Scratch.Get "image" }}
{{ define "img" }}
{{ $image := .Scratch.Get "image" }}
<img src='{{ $image.RelPermalink }}' class='{{ .Get "class" }}' alt="{{ .Inner | plainify }}" />
{{ end }}
{{ if .Inner }}
<figure>
<img src="{{ $image.RelPermalink }}" class='{{ .Get "class" }}' />
{{ template "img" . }}
<figcaption>
<small>{{ .Inner }}</small>
</figcaption>
</figure>
{{ else }}
<img src="{{ $image.RelPermalink }}" class='{{ .Get "class" }}' />
{{ template "img" . }}
{{ end }}