mirror of
https://github.com/Sped0n/bridget.git
synced 2026-04-14 10:09:31 -07:00
refactor(imageJSON.html): modify image resizing logic to generate separate low resolution and high resolution image URLs, heights, and widths to improve performance and optimize image loading
24 lines
763 B
HTML
24 lines
763 B
HTML
{{- $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 "1000x webp Lanczos q70" }}
|
|
{{ $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 -}}
|