44 lines
2.1 KiB
HTML
44 lines
2.1 KiB
HTML
{{ $img := $.Page.Resources.GetMatch (.Get "src") }}
|
|
{{ $file := $.Page.Resources.GetMatch (.Get "link") }}
|
|
|
|
<figure{{ with .Get "class" }} class="{{ . }}"{{ end }}>
|
|
{{- if .Get "link" -}}
|
|
{{- if $file }}
|
|
<a href="{{ $file.RelPermalink }}"{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
|
|
{{ else }}
|
|
<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
|
|
{{ end }}
|
|
{{- end -}}
|
|
{{ if $img }}
|
|
<img class="figure__image"
|
|
{{ with $img.Resize (printf "%dx%d webp" $img.Width $img.Height) }}
|
|
src="{{ .RelPermalink }}"
|
|
{{ end }}
|
|
{{- if or ($img.Params.alt) (.Get "caption") }}
|
|
alt="{{ with $img.Params.alt }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
|
|
{{- end -}}
|
|
{{- with $img.Params.title }} title="{{ . }}"{{ end -}}
|
|
width="{{ $img.Width }}"
|
|
height="{{ $img.Height }}"
|
|
/>
|
|
{{ end }}
|
|
{{- if .Get "link" }}</a>{{ end -}}
|
|
{{- if or (.Get "caption") ($img.Params.attr) -}}
|
|
<figcaption class="figure__caption{{ if not (.Get "caption") }} figure__caption--no-height{{ end }}">
|
|
{{- if $img.Params.attrlink -}}
|
|
<a class="figcaption__attrlink" href="{{ $img.Params.attrlink }}"
|
|
{{- with $img.Params.attrtarget }} target="{{ . }}"{{ end -}}
|
|
{{- with $img.Params.attrrel }} rel="{{ . }}"{{ end -}}
|
|
>
|
|
{{- end -}}
|
|
{{- with $img.Params.attr -}}<p class="figcaption__attr">{{ . | safeHTML }}{{ with $img.Params.attrlicence }} <span class="figcaption__licence">{{ . | safeHTML }}</span>{{ end }}</p>{{- end -}}
|
|
{{- if $img.Params.attrlink -}}
|
|
</a>
|
|
{{- end -}}
|
|
{{- with $img.Params.title -}}<h4 class="figcaption__title">{{ . }}</h4>{{- end -}}
|
|
{{- if .Get "caption" -}}
|
|
<p class="figcaption__caption">{{ .Get "caption" | markdownify }}</p>
|
|
{{- end -}}
|
|
</figcaption>
|
|
{{- end -}}
|
|
</figure>
|