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

29 lines
1 KiB
HTML

{{- $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 }}
<img class="article-img" width="{{ $img.Width }}" height="{{ $img.Height }}" src="{{ $img.RelPermalink }}" alt="{{ $.Text }}" />
{{ end }}
</a>
<figcaption><i>{{ $.Text | safeHTML }}</i></figcaption>
</figure>
{{- else -}}
<em>Unable to find image {{ $url }}!</em>
{{- end -}}