Use <figure> for images and videos

This commit is contained in:
2021-10-19 13:57:39 -05:00
parent 61ac27bdf9
commit 937a80bc17
6 changed files with 61 additions and 39 deletions

View File

@ -0,0 +1,22 @@
<figure>
{{ $img := $.Page.Resources.GetMatch (.Get "src") | resources.Fingerprint "sha512" }}
{{ if .Get "href" }}<a href="{{ .Get "href" }}">{{ end }}
<img src="{{ $img.Permalink }}"
{{ with $img.Title }}
alt="{{ . }}"
{{ end }}
{{ with .Get "width" }}width="{{ . }}"{{ end }}
{{ with .Get "height" }}height="{{ . }}"{{ end }}
/>
{{ if .Get "href" }}</a>{{ end }}
{{ with $img.Title }}
<figcaption>
{{ . | markdownify }}
</figcaption>
{{ end }}
</figure>

View File

@ -1,26 +0,0 @@
<figure>
{{ $img := $.Page.Resources.GetMatch (.Get "resrc") | resources.Fingerprint "sha512" }}
{{ if .Get "href" }}<a href="{{ .Get "href" }}">{{ end }}
<img src="{{ $img.Permalink }}"
{{ if or (.Get "alt") (.Get "caption") }}
alt="{{ with .Get "alt" -}}
{{ . -}}
{{ else -}}
{{ .Get "caption" | markdownify -}}
{{ end -}}"
{{ end }}
{{ with .Get "width" }} width="{{ . }}" {{ end }}
{{ with .Get "height" }} height="{{ . }}" {{ end }}
/>
{{ if .Get "href" }}</a>{{ end }}
{{ with .Get "caption" }}
<figcaption>
{{ . | markdownify }}
</figcaption>
{{ end }}
</figure>

View File

@ -0,0 +1,18 @@
<figure>
{{ $vid := $.Page.Resources.GetMatch (.Get "src") | resources.Fingerprint "sha512" }}
{{ if .Get "href" }}<a href="{{ .Get "href" }}">{{ end }}
<video controls>
<source src="{{ $vid.Permalink }}" alt="{{ $vid.Title }}">
{{ i18n "browser_no_video_support" }}
</video>
{{ if .Get "href" }}</a>{{ end }}
{{ with $vid.Title }}
<figcaption>
{{ . | markdownify }}
</figcaption>
{{ end }}
</figure>

View File

@ -1,4 +0,0 @@
<video controls>
<source src="{{ .Get "src" }}" alt="{{ .Get "title" }}">
{{ i18n "browser_no_video_support" }}
</video>