mmote.ru/themes/mmotium/layouts/_default/_markup/render-image.html

26 lines
1.0 KiB
HTML

<figure class="image-wrapper">
{{/* Remote image */ -}}
{{ if or (hasPrefix .Destination "https://") (hasPrefix .Destination "http://") }}
<a class="spotlight" data-title="{{ .Title | default "false" }}" href="{{ .Destination | safeURL }}" >
<img src="{{ .Destination | safeURL }}" alt="{{.Text}}" />
</a>
{{/* Local image */ -}}
{{ else }}
{{- $img := .Page.Resources.GetMatch .Destination -}}
{{- $resizeMimes := slice "image/png" "image/jpeg" -}}
{{ if $img -}}
<a class="spotlight" data-title="{{ .Title | default "false" }}" href="{{ $img.RelPermalink | safeURL }}" >
{{ if in $resizeMimes $img.MediaType.Type -}}
<img src="{{ ($img.Fit "1024x1024").RelPermalink | safeURL }}" alt="{{.Text}}" />
{{- else -}}
<img src="{{ $img.RelPermalink | safeURL }}" alt="{{.Text}}" />
{{- end -}}
</a>
{{- else -}}
<img src="/images/image-error.png" alt="{{.Text}}" />
{{- end -}}
{{- end -}}
{{ if .Title }}<figcaption>{{ .Title }}</figcaption>{{ end }}
</figure>