From 833a846bbff79f87ebe8cdd196675a205e6684dc Mon Sep 17 00:00:00 2001
From: alexisben <alex@noesya.coop>
Date: Fri, 30 Dec 2022 16:54:58 +0100
Subject: [PATCH] fix glightbox url

---
 config.yaml                                   |  5 ++++-
 layouts/partials/GetLightboxUrl               | 21 +++++++++++++------
 .../partials/blocks/templates/chapter.html    |  2 +-
 layouts/partials/footer/logo.html             |  2 +-
 layouts/partials/header/logo.html             |  2 +-
 5 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/config.yaml b/config.yaml
index c71cc04a..c338f51b 100644
--- a/config.yaml
+++ b/config.yaml
@@ -23,4 +23,7 @@ params:
       truncate_description: 200 # Set to 0 to disable truncate
   home:
     toc:
-      disabled: true
\ No newline at end of file
+      disabled: true
+  logo:
+    header: "/assets/images/logo.svg"
+    footer: "/assets/images/logo.svg"
\ No newline at end of file
diff --git a/layouts/partials/GetLightboxUrl b/layouts/partials/GetLightboxUrl
index 8914ac07..e4993a61 100644
--- a/layouts/partials/GetLightboxUrl
+++ b/layouts/partials/GetLightboxUrl
@@ -1,8 +1,17 @@
-{{- $lightbox_sizes := "1920x2560" -}}
-{{- $image := partial "GetMedia" .id -}}
-{{- $url := $image.url -}}
-{{- if site.Params.keycdn -}}
-  {{- $url = $image.direct_url -}}
+{{ $id := . }}
+{{ if isset . "id" }}
+  {{ $id = .id }}
+{{ end }}
+{{ $lightbox_sizes := "1920x2560" }}
+{{ $image := partial "GetMedia" $id }}
+{{ $url := "" }}
+
+{{ if $image }}
+  {{- $url = $image.url -}}
+  {{- if site.Params.keycdn -}}
+    {{- $url = $image.direct_url -}}
+  {{- end -}}
+  {{ $url = partial "GetImageUrl" (dict "url" $url "size" $lightbox_sizes ) }}
 {{- end -}}
 
-{{ return partial "GetImageUrl" (dict "url" $url "size" $lightbox_sizes ) }}
\ No newline at end of file
+{{ return $url }}
diff --git a/layouts/partials/blocks/templates/chapter.html b/layouts/partials/blocks/templates/chapter.html
index b95f37ed..bb0c6750 100644
--- a/layouts/partials/blocks/templates/chapter.html
+++ b/layouts/partials/blocks/templates/chapter.html
@@ -40,7 +40,7 @@
             <figure class="{{- $image_class -}}">
               <a class="glightbox"
                 data-glightbox="type: image;{{ if .credit }}description: {{ partial "PrepareHTML" .credit }}{{ end }}"
-                href="{{ partial "GetLightboxUrl" .image }}"
+                href="{{- partial "GetLightboxUrl" .image -}}"
                 title="{{- i18n "commons.lightbox.link.title" -}}"
                 >
                 {{ partial "commons/image.html"
diff --git a/layouts/partials/footer/logo.html b/layouts/partials/footer/logo.html
index 5cdf05f6..0e0bead4 100644
--- a/layouts/partials/footer/logo.html
+++ b/layouts/partials/footer/logo.html
@@ -1,3 +1,3 @@
-{{ $file := "/assets/images/logo.svg" }}
+{{ $file := site.Params.logo.footer }}
 {{ $fileDimensions := partial "GetImageDimensions" (dict "context" . "file" $file "static" true) }}
 <a class="logo" href="{{ site.BaseURL }}"><img src="{{ $file }}" alt="{{ site.Title }}" height="{{ index $fileDimensions 1 }}" width="{{ index $fileDimensions 0 }}" loading="lazy"></a>
diff --git a/layouts/partials/header/logo.html b/layouts/partials/header/logo.html
index 7ce7b481..1f159730 100644
--- a/layouts/partials/header/logo.html
+++ b/layouts/partials/header/logo.html
@@ -1,3 +1,3 @@
-{{ $file := "/assets/images/logo.svg" }}
+{{ $file := site.Params.logo.header }}
 {{ $fileDimensions := partial "GetImageDimensions" (dict "context" . "file" $file "static" true) }}
 <a class="logo" href="{{ site.BaseURL }}"><img src="{{ $file }}" alt="{{ site.Title }}" height="{{ index $fileDimensions 1 }}" width="{{ index $fileDimensions 0 }}"></a>
-- 
GitLab