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

32 lines
1.1 KiB
HTML
Raw Normal View History

2023-01-07 11:53:48 +03:00
{{ if .IsBlock }}
2023-01-01 18:21:01 +03:00
<figure class="image-wrapper">
2023-01-07 11:53:48 +03:00
{{ end }}
2023-01-01 18:21:01 +03:00
{{/* 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:53:48 +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 -}}
2023-01-07 11:53:48 +03:00
<a class="spotlight" data-title="{{ .Title | default "false" }}" href="{{ $img.RelPermalink | safeURL }}">
2023-01-01 18:21:01 +03:00
{{ if in $resizeMimes $img.MediaType.Type -}}
2023-01-07 11:53:48 +03:00
<img src="{{ ($img.Fit "1024x1024").RelPermalink | safeURL }}" alt="{{.Text}}">
2023-01-01 18:21:01 +03:00
{{- else -}}
2023-01-07 11:53:48 +03:00
<img src="{{ $img.RelPermalink | safeURL }}" alt="{{.Text}}">
2023-01-01 18:21:01 +03:00
{{- end -}}
</a>
{{- else -}}
2023-01-07 11:53:48 +03:00
<img src="/images/image-error.png" alt="{{.Text}}">
2023-01-01 18:21:01 +03:00
{{- end -}}
{{- end -}}
2023-01-07 11:53:48 +03:00
{{ if and (.IsBlock) (.Title) }}<figcaption>{{ .Title }}</figcaption>{{ end }}
{{ if .IsBlock }}
2023-01-01 18:21:01 +03:00
</figure>
2023-01-07 11:53:48 +03:00
{{ end }}