mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2024-11-23 18:31:45 +01:00
22 lines
No EOL
944 B
HTML
22 lines
No EOL
944 B
HTML
{{- $image := .Page.Resources.GetMatch (printf "%s" (.Destination | safeURL)) -}}
|
|
{{- if $image -}}
|
|
{{- $small := $image.Resize "480x" -}}
|
|
{{- $big := $image.Resize "1024x" -}}
|
|
{{- $alt := .PlainText | safeHTML -}}
|
|
{{- $caption := "" -}}
|
|
{{- with $alt -}}
|
|
{{- $caption = . | safeHTML -}}
|
|
{{- end -}}
|
|
<figure>
|
|
<a href="{{ $image.RelPermalink }}" data-size="{{ $image.Width }}x{{ $image.Height }}">
|
|
<img srcset="{{ $small.RelPermalink }} 480w, {{ $big.RelPermalink }} 1024w"
|
|
src="{{ $image.RelPermalink }}" width="{{ $image.Width }}" height="{{ $image.Height }}" loading="lazy"
|
|
alt="{{ if $alt }}{{ $alt }}{{ else if $caption }}{{ $caption | markdownify | plainify }}{{ else }} {{ end }}">
|
|
</a>
|
|
{{ with $caption }}
|
|
<figcaption>{{ . | markdownify }}</figcaption>
|
|
{{ end }}
|
|
</figure>
|
|
{{- else -}}
|
|
<img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" {{ with .Title }} title="{{ . }}"{{ end }} />
|
|
{{- end -}} |