From 945a114f08b18b2e1ca272b4f06b061a333b7366 Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Sat, 22 Feb 2025 17:31:52 +0100 Subject: [PATCH] Allow changing of gallery image size --- assets/js/gallery.js | 2 +- layouts/partials/albums/images.json | 11 ++++++++++- layouts/partials/head/js.html | 10 ++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/assets/js/gallery.js b/assets/js/gallery.js index 6177906..0594b85 100644 --- a/assets/js/gallery.js +++ b/assets/js/gallery.js @@ -10,7 +10,7 @@ $(function(){ }); $('#gallery').nanogallery2({ - thumbnailHeight: 200, + thumbnailHeight: galleryUseHeight, thumbnailWidth: 'auto', thumbnailGutterWidth: 10, diff --git a/layouts/partials/albums/images.json b/layouts/partials/albums/images.json index b3c55b5..4d87756 100644 --- a/layouts/partials/albums/images.json +++ b/layouts/partials/albums/images.json @@ -1,6 +1,15 @@ {{- $first := true -}} {{- $filter := images.AutoOrient -}} {{- $teaser := .Resources.GetMatch "thumbnail.jpg" -}} +{{- $galleryHeight := 200 }} +{{- with site.Params.galleryUseHeight }} + {{- $galleryHeight = . | int }} +{{- end }} +{{- with .Page.Params.galleryUseHeight }} + {{- $galleryHeight = . | int }} +{{- end }} +{{- $galleryWidth := mul $galleryHeight 1.5 | math.Round | int -}} +{{- $gallerySize := printf "%dx%d" $galleryWidth $galleryHeight -}} {{- range .Resources.ByType "image" -}} {{- if not (eq $teaser .) -}} {{- if not $first }}, {{ end }} @@ -11,7 +20,7 @@ "url": "{{ .RelPermalink }}", "width": "{{ .Width }}", "height": "{{ .Height }}", - "thumbnail": "{{ (.Fit "300x200").RelPermalink }}" + "thumbnail": "{{ (.Fit $gallerySize).RelPermalink }}" } {{- end -}} {{- end -}} diff --git a/layouts/partials/head/js.html b/layouts/partials/head/js.html index da2625c..b8eb6b6 100644 --- a/layouts/partials/head/js.html +++ b/layouts/partials/head/js.html @@ -13,4 +13,14 @@ +