m2.nz/themes/LoveIt/layouts/partials/plugin/img.html

47 lines
2.0 KiB
HTML
Raw Normal View History

2024-04-07 02:32:03 +00:00
{{- /* lazysizes and lightgallery */ -}}
2022-05-08 06:47:31 +00:00
{{- $src := .Src -}}
2024-04-07 02:32:03 +00:00
{{- $width := .Width -}}
{{- $height := .Height -}}
{{- with dict "Path" $src "Resources" .Resources | partial "function/resource.html" -}}
2022-05-08 06:47:31 +00:00
{{- $src = .RelPermalink -}}
2024-04-07 02:32:03 +00:00
{{- $width = $width | default .Width -}}
{{- $height = $height | default .Height -}}
2022-05-08 06:47:31 +00:00
{{- end -}}
{{- $small := .SrcSmall | default $src -}}
{{- with dict "Path" .SrcSmall "Resources" .Resources | partial "function/resource.html" -}}
{{- $small = .RelPermalink -}}
{{- end -}}
{{- $large := .SrcLarge | default $src -}}
{{- with dict "Path" .SrcLarge "Resources" .Resources | partial "function/resource.html" -}}
{{- $large = .RelPermalink -}}
{{- end -}}
{{- $alt := .Alt | default $src -}}
{{- $loading := resources.Get "svg/loading.svg" | minify -}}
{{- if .Linked -}}
<a class="lightgallery" href="{{ $large | safeURL }}" title="{{ .Title | default $alt }}" data-thumbnail="{{ $small | safeURL }}"{{ with .Caption }} data-sub-html="<h2>{{ . }}</h2>{{ with $.Title }}<p>{{ . }}</p>{{ end }}"{{ end }}{{ with .Rel }} rel="{{ . }}"{{ end }}>
<img
class="lazyload{{ with .Class }} {{ . }}{{ end }}"
src="{{ $loading.RelPermalink }}"
2024-04-07 02:32:03 +00:00
data-src="{{ $src | safeURL }}"
data-srcset="{{ $small | safeURL }}, {{ $src | safeURL }} 1.5x, {{ $large | safeURL }} 2x"
2022-05-08 06:47:31 +00:00
data-sizes="auto"
2024-04-07 02:32:03 +00:00
alt="{{ $alt }}"
{{- with $width }} width="{{ . }}"{{ end }}
{{- with $height }} height="{{ . }}"{{ end }} />
2022-05-08 06:47:31 +00:00
</a>
{{- else -}}
<img
class="lazyload{{ with .Class }} {{ . }}{{ end }}"
src="{{ $loading.RelPermalink }}"
2024-04-07 02:32:03 +00:00
data-src="{{ $src | safeURL }}"
data-srcset="{{ $small | safeURL }}, {{ $src | safeURL }} 1.5x, {{ $large | safeURL }} 2x"
2022-05-08 06:47:31 +00:00
data-sizes="auto"
alt="{{ $alt }}"
2024-04-07 02:32:03 +00:00
title="{{ .Title | default $alt }}"
{{- with $width }} width="{{ . }}"{{ end }}
{{- with $height }} height="{{ . }}"{{ end }} />
2022-05-08 06:47:31 +00:00
{{- end -}}