2018-07-24 00:03:34 +00:00
|
|
|
{{ $fig := newScratch }}
|
|
|
|
{{ if .Get "caption" }}
|
2018-07-26 22:41:33 +00:00
|
|
|
{{ $fig.Set "caption" (.Get "caption") }}
|
2018-07-24 00:03:34 +00:00
|
|
|
{{ else if .Get "alt" }}
|
2018-07-26 22:41:33 +00:00
|
|
|
{{ $fig.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:03:07 +00:00
|
|
|
{{ with .Get "width" }}width="{{ . }}"{{ end }}
|
2018-07-27 23:06:12 +00:00
|
|
|
{{ with .Get "height" }}width="{{ . }}"{{ end }} />
|
|
|
|
{{ if .Get "link"}}</a>{{ end }}
|
|
|
|
<!-- caption and attr-->
|
|
|
|
{{ if ($fig.Get "caption") }}
|
2018-07-21 07:08:41 +00:00
|
|
|
<figcaption>
|
2018-07-27 23:06:12 +00:00
|
|
|
<span class="img--caption">
|
|
|
|
Figure {{ $.Page.Scratch.Get "fig" }}. {{ $fig.Get "caption" | markdownify | plainify }}
|
|
|
|
{{ 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-07-26 22:41:33 +00:00
|
|
|
{{ $fig.Delete "caption"}}
|