2018-07-24 00:03:34 +00:00
|
|
|
{{ if .Get "caption" }}
|
2018-09-22 23:55:37 +00:00
|
|
|
{{ $.Scratch.Set "caption" (.Get "caption") }}
|
2018-07-24 00:03:34 +00:00
|
|
|
{{ else if .Get "alt" }}
|
2018-09-22 23:55:37 +00:00
|
|
|
{{ $.Scratch.Set "caption" (.Get "alt") }}
|
2018-07-24 00:03:34 +00:00
|
|
|
{{ end }}
|
2018-07-27 23:06:12 +00:00
|
|
|
<!-- resolve absolute image path -->
|
|
|
|
{{ $permalink := $.Page.Permalink }}
|
|
|
|
{{ $image := .Get "src" }}
|
|
|
|
{{ $image_link_absolute := (findRE "^/" $image) }}
|
2018-07-21 07:08:41 +00:00
|
|
|
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}>
|
2018-07-27 23:06:12 +00:00
|
|
|
{{ if .Get "link"}}
|
|
|
|
<a href="{{ .Get "link" }}"
|
|
|
|
{{ with .Get "target" }} target="{{ . }}"{{ end }}
|
|
|
|
{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
|
|
|
|
{{ 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 }}"
|
2018-07-29 21:41:49 +00:00
|
|
|
{{ else if .Get "caption" }}alt="{{ .Get "caption" | markdownify | plainify }}"
|
|
|
|
{{ end }}
|
2018-07-26 22:41:33 +00:00
|
|
|
{{ with .Get "align" }}align="{{ . }}"{{ end }}
|
2018-07-29 23:23:19 +00:00
|
|
|
{{ with .Get "height" }}width="{{ . }}"{{ end }}
|
|
|
|
{{ with .Get "width" }}width="{{ . }}"{{ end }} style="max-width: 100%;"
|
|
|
|
/>
|
2018-07-27 23:06:12 +00:00
|
|
|
{{ if .Get "link"}}</a>{{ end }}
|
|
|
|
<!-- caption and attr-->
|
2018-09-22 23:55:37 +00:00
|
|
|
{{ if ($.Scratch.Get "caption") }}
|
2018-07-21 07:08:41 +00:00
|
|
|
<figcaption>
|
2018-07-27 23:06:12 +00:00
|
|
|
<span class="img--caption">
|
2018-09-22 23:55:37 +00:00
|
|
|
Figure {{ $.Page.Scratch.Get "fig" }}. {{ $.Scratch.Get "caption" | markdownify | plainify }}
|
2018-07-27 23:06:12 +00:00
|
|
|
{{ if .Get "attr" }}
|
2018-07-29 22:17:05 +00:00
|
|
|
[{{- with .Get "attrlink"}}<a href="{{ . }}">{{ end }}{{ .Get "attr" | markdownify }}{{ if .Get "attrlink"}}</a>{{ end -}}]
|
2018-07-27 23:06:12 +00:00
|
|
|
{{ end }}
|
|
|
|
</span>
|
2018-07-21 07:08:41 +00:00
|
|
|
</figcaption>
|
2018-07-26 22:41:33 +00:00
|
|
|
{{ end }}
|
2018-07-21 07:08:41 +00:00
|
|
|
</figure>
|
2018-07-24 00:03:34 +00:00
|
|
|
{{ .Page.Scratch.Add "fig" 1 }}
|
2018-09-22 23:55:37 +00:00
|
|
|
{{ $.Scratch.Delete "caption"}}
|