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

26 lines
1.0 KiB
HTML
Raw Normal View History

2023-01-01 18:21:01 +03:00
<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 }}" >
2023-01-07 11:09:28 +03:00
<img src="{{ .Destination | safeURL }}" alt="{{.Text}}" />
2023-01-01 18:21:01 +03:00
</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 -}}
2023-01-07 11:09:28 +03:00
<img src="{{ ($img.Fit "1024x1024").RelPermalink | safeURL }}" alt="{{.Text}}" />
2023-01-01 18:21:01 +03:00
{{- else -}}
2023-01-07 11:09:28 +03:00
<img src="{{ $img.RelPermalink | safeURL }}" alt="{{.Text}}" />
2023-01-01 18:21:01 +03:00
{{- end -}}
</a>
{{- else -}}
2023-01-07 11:09:28 +03:00
<img src="/images/image-error.png" alt="{{.Text}}" />
2023-01-01 18:21:01 +03:00
{{- end -}}
{{- end -}}
{{ if .Title }}<figcaption>{{ .Title }}</figcaption>{{ end }}
</figure>