Files
bridget/layouts/partials/resources/imageJSON.html

31 lines
1008 B
HTML

{{- $Page := .Page -}}
{{- $params := .Page.Params | merge .Site.Params.Page -}}
{{- $gallery := site.GetPage .Path -}}
{{- with $gallery.Resources.ByType "image" -}}
{{- $index := len . -}}
{{- $Page.Scratch.Add "img" slice -}}
{{- range sort . "Name" "desc" -}}
{{- $image := . -}}
{{- $index = sub $index 1 -}}
{{- $alt := .Name -}}
{{- with $params.unifiedAlt -}}
{{- $alt = . -}}
{{- end -}}
{{- $lores := .Resize "800x webp Lanczos q60" -}}
{{- $hires := .Resize "2500x webp Lanczos q75" -}}
{{- $Page.Scratch.Add "img" (dict
"index" (int $index)
"alt" (string $alt)
"loUrl" (string $lores.RelPermalink)
"loImgH" (int $lores.Height)
"loImgW" (int $lores.Width)
"hiUrl" (string $hires.RelPermalink)
"hiImgH" (int $hires.Height)
"hiImgW" (int $hires.Width)
)
-}}
{{- end -}}
<script id="imagesSource" type="application/json">{{ $Page.Scratch.Get "img" | jsonify | safeJS }}</script>
{{- end -}}