{{- $Page := .Page -}}

{{ $gallery := site.GetPage .Path }}
{{ with $gallery.Resources.ByType "image" }}
  {{ $index := len . }}
  {{ $Page.Scratch.Add "img" slice }}
  {{ range . }}
    {{ $index = sub $index 1 }}
    {{ $lores := .Resize "800x webp Lanczos q60" }}
    {{ $hires := .Resize "2500x webp Lanczos q75" }}
    {{ $Page.Scratch.Add "img" (dict
      "index" (int $index)
      "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 -}}
