{{- if not ($.Page.Scratch.Get "figurecount") }}{{ end }} {{- $.Page.Scratch.Add "figurecount" 1 -}} {{- $thumb := .Get "src" | default (printf "%s." (.Get "thumb") | replace (.Get "link") ".") }} {{- $thumbURL := "" }} {{- if or (hasPrefix $thumb "http://") (hasPrefix $thumb "https://") }} {{- $thumbURL = $thumb }} {{- else }} {{- $thumbURL = $thumb | relURL }} {{- end }} {{- $linkURL := "" }} {{- $link := .Get "link" | default (.Get "src") }} {{- if or (hasPrefix $link "http://") (hasPrefix $link "https://") }} {{- $linkURL = $link }} {{- else }} {{- $linkURL = $link | relURL }} {{- end }}
{{ with $linkURL }}{{ end }} {{- if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
{{- with .Get "title" }}

{{.}}

{{ end }} {{- if or (.Get "caption") (.Get "attr")}}

{{- .Get "caption" -}} {{- with .Get "attrlink"}}{{ .Get "attr" }}{{ else }}{{ .Get "attr"}}{{ end -}}

{{- end }}
{{- end }}