bunteshaus.de/themes/buha/layouts/_default/_markup/render-image.html

38 lines
1.5 KiB
HTML
Raw Normal View History

2022-04-10 00:53:31 +02:00
{{- if strings.HasPrefix .Destination "http" -}}
2022-04-11 15:45:49 +02:00
<a href="{{- .Destination -}}" class="no_underline">
2022-04-10 00:53:31 +02:00
<img loading="lazy"
src="{{ .Destination | safeURL }}"
alt="{{ .Text }}"
{{ with .Title}} title="{{ . }}"{{ end }} />
2022-04-11 15:45:49 +02:00
<div class="dfjcc">{{ .Text }}</div>
2022-04-10 00:53:31 +02:00
</a>
{{- else -}}
{{ if .Page.Resources.ByType "image" }}
{{ $nr := .Destination }}
{{- $pic := index (.Page.Resources.ByType "image") (int $nr) -}}
{{- $image := .Page.Resources.GetMatch (printf "%s" ($pic | safeURL)) -}}
2022-04-21 11:54:27 +02:00
{{ if ne $image nil }}
2022-04-10 00:53:31 +02:00
<div>
2022-04-11 15:45:49 +02:00
<a href="{{- $image.Permalink -}}" class="no_underline">
{{- $permalink := "" -}}
2022-04-10 00:53:31 +02:00
2022-04-11 15:45:49 +02:00
{{- if ne $image nil -}}
{{- $permalink = $image.RelPermalink -}}
{{- else -}}
{{- $image = imageConfig (printf "static/%s" (.Destination | safeURL)) -}}
{{- $permalink = (printf "/%s" (.Destination | safeURL)) -}}
{{- end -}}
2022-04-10 00:53:31 +02:00
2022-04-11 15:45:49 +02:00
<div class="dfjcc"><img loading="lazy"
src="{{ $permalink }}"
alt="{{ .Text }}"
{{ with .Title}} title="{{ . }}"{{ end }}
width={{ $image.Width }}
height="{{ $image.Height }}" /></div>
<div class="dfjcc">{{ .Text }}</div>
</a>
2022-04-10 00:53:31 +02:00
</div>
2022-04-21 11:54:27 +02:00
{{ end }}
2022-04-10 00:53:31 +02:00
{{ end }}
{{- end -}}