53 lines
1.8 KiB
HTML
53 lines
1.8 KiB
HTML
|
{{ if .Get "caption" }}
|
||
|
{{ $.Scratch.Set "caption" (.Get "caption") }}
|
||
|
{{ else if .Get "alt" }}
|
||
|
{{ $.Scratch.Set "caption" (.Get "alt") }}
|
||
|
{{ end }}
|
||
|
<!-- resolve absolute image path -->
|
||
|
{{ $permalink := $.Page.Permalink }}
|
||
|
{{ $image := .Get "src" }}
|
||
|
{{ $image_link_absolute := (findRE "^/" $image) }}
|
||
|
<figure
|
||
|
{{ with .Get "class" }}class="{{.}}"{{ end }}
|
||
|
{{ with .Get "width" }}style="width: {{ . }};"{{ end }}
|
||
|
{{ with .Get "height" }}style="height: {{ . }};"{{ end }}
|
||
|
>
|
||
|
<a
|
||
|
{{ if .Get "lightbox" }}
|
||
|
data-lightbox="{{ .Get "lightbox" | markdownify | plainify }}"
|
||
|
{{ else }}
|
||
|
data-lightbox="image-{{ $image }}"
|
||
|
{{ end }}
|
||
|
{{ if $image_link_absolute }}
|
||
|
href="{{ $image | absURL }}"
|
||
|
{{ else }}
|
||
|
href="{{ (printf "%s%s" $permalink $image) }}"
|
||
|
{{ end }}
|
||
|
{{ with .Get "target" }} target="{{ . }}"{{ end }}
|
||
|
{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
|
||
|
<img
|
||
|
{{ if $image_link_absolute }}
|
||
|
src="{{ $image | absURL }}"
|
||
|
{{ else }}
|
||
|
src="{{ (printf "%s%s" $permalink $image) }}"
|
||
|
{{ end }}
|
||
|
{{ if .Get "alt" }}alt="{{ .Get "alt" | markdownify | plainify }}"
|
||
|
{{ else if .Get "caption" }}alt="{{ .Get "caption" | markdownify | plainify }}"
|
||
|
{{ end }}
|
||
|
{{ with .Get "align" }}align="{{ . }}"{{ end }}
|
||
|
/>
|
||
|
</a>
|
||
|
<!-- caption and attr-->
|
||
|
{{ if ($.Scratch.Get "caption") }}
|
||
|
<figcaption>
|
||
|
<span class="img--caption">
|
||
|
{{ $.Scratch.Get "caption" | markdownify | plainify }}
|
||
|
{{ if .Get "attr" }}
|
||
|
[{{- with .Get "attrlink"}}<a href="{{ . }}">{{ end }}{{ .Get "attr" | markdownify }}{{ if .Get "attrlink"}}</a>{{ end -}}]
|
||
|
{{ end }}
|
||
|
</span>
|
||
|
</figcaption>
|
||
|
{{ end }}
|
||
|
</figure>
|
||
|
{{ .Page.Scratch.Add "fig" 1 }}
|
||
|
{{ $.Scratch.Delete "caption"}}
|