redstrate.com/themes/retro/layouts/_default/_markup/render-image.html

32 lines
1.1 KiB
HTML
Raw Normal View History

2023-03-30 21:47:18 -04:00
{{- $url := .Destination | safeURL -}}
{{- $img := .Page.Resources.GetMatch .Destination -}}
{{- if and (not $img) .Page.File -}}
{{ with .Page.File }}
{{ $path := path.Join .Dir $url }}
{{- $img = resources.Get $path -}}
{{ end }}
{{- end -}}
{{- if and (not $img) .Page.File -}}
{{- $img = resources.Get .Destination -}}
{{- end -}}
{{- with $img -}}
<figure>
<a href="{{ $img.RelPermalink }}" data-download="true">
{{ if eq .MediaType.SubType "svg" }}
<img class="article-img" src="{{ $img.RelPermalink }}" alt="{{ $.Text }}" />
{{ else }}
{{ with ($img).Resize "400x bmp" }}
<img class="article-img" width="{{ .Width }}" height="{{ .Height }}" src="{{ .RelPermalink }}" alt="{{ $.Text }}" />
{{ end }}
{{ end }}
</a>
<figcaption><i>{{ $.Text | safeHTML }}</i></figcaption>
</figure>
{{- else -}}
<em>Unable to find image {{ $url }}!</em>
{{- end -}}