From f430edf615d2cb61e5cef733928ed1ad6f54a2d6 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Thu, 20 Apr 2023 16:56:42 +0200 Subject: [PATCH] lightbox can be disabled in config --- config.yaml | 1 + .../blocks/templates/gallery/carousel.html | 27 ++++++++++--------- .../blocks/templates/gallery/grid.html | 15 ++++++----- layouts/partials/blocks/templates/image.html | 27 ++++++++++--------- layouts/partials/header/hero.html | 13 +++++---- 5 files changed, 48 insertions(+), 35 deletions(-) diff --git a/config.yaml b/config.yaml index a931be19..090f7c8b 100644 --- a/config.yaml +++ b/config.yaml @@ -41,6 +41,7 @@ params: image_sizes: design_system: lightbox: + disabled: false # TODO mobile et tablet mobile: 1920x2560 tablet: 1920x2560 diff --git a/layouts/partials/blocks/templates/gallery/carousel.html b/layouts/partials/blocks/templates/gallery/carousel.html index a787ab3f..761d2008 100644 --- a/layouts/partials/blocks/templates/gallery/carousel.html +++ b/layouts/partials/blocks/templates/gallery/carousel.html @@ -14,18 +14,21 @@ {{- $image := partial "GetMedia" .file -}} {{- if $image -}} <figure{{ if $is_carousel }} class="splide__slide"{{ end }}> - <a class="glightbox" - data-glightbox="type: image;{{ if .credit }}description: {{ partial "PrepareHTML" .credit }}{{ end }}" - href="{{ partial "GetLightboxUrl" (dict "id" .id) }}" - title="{{- i18n "commons.lightbox.link.title" -}}" - > - {{ partial "commons/image.html" - (dict - "image" .id - "alt" .alt - "sizes" site.Params.image_sizes.blocks.gallery.carousel - )}} - </a> + {{ if not site.Params.image_sizes.design_system.lightbox.disabled }} + <a class="glightbox" + data-glightbox="type: image;{{ if .credit }}description: {{ partial "PrepareHTML" .credit }}{{ end }}" + href="{{ partial "GetLightboxUrl" (dict "id" .id) }}" + title="{{- i18n "commons.lightbox.link.title" -}}"> + {{ end }} + {{ partial "commons/image.html" + (dict + "image" .id + "alt" .alt + "sizes" site.Params.image_sizes.blocks.gallery.carousel + )}} + {{ if not site.Params.image_sizes.design_system.lightbox.disabled }} + </a> + {{ end }} {{ if or .text .credit }} <figcaption> {{ if .text }} diff --git a/layouts/partials/blocks/templates/gallery/grid.html b/layouts/partials/blocks/templates/gallery/grid.html index fe5a4a1c..84af74fa 100644 --- a/layouts/partials/blocks/templates/gallery/grid.html +++ b/layouts/partials/blocks/templates/gallery/grid.html @@ -4,18 +4,21 @@ {{- $image := partial "GetMedia" .id -}} {{- if $image -}} <figure> - <a class="glightbox" - data-glightbox="type: image;{{ if .credit }}description: {{ partial "PrepareHTML" .credit }}{{ end }}" - href="{{ partial "GetLightboxUrl" (dict "id" .id) }}" - title="{{- i18n "commons.lightbox.link.title" -}}" - > + {{ if not site.Params.image_sizes.design_system.lightbox.disabled }} + <a class="glightbox" + data-glightbox="type: image;{{ if .credit }}description: {{ partial "PrepareHTML" .credit }}{{ end }}" + href="{{ partial "GetLightboxUrl" (dict "id" .id) }}" + title="{{- i18n "commons.lightbox.link.title" -}}"> + {{ end }} {{ partial "commons/image.html" (dict "image" .file "alt" .alt "sizes" site.Params.image_sizes.blocks.gallery.grid )}} - </a> + {{ if not site.Params.image_sizes.design_system.lightbox.disabled }} + </a> + {{ end }} {{ if .text }} <figcaption> {{- partial "PrepareHTML" .text -}} diff --git a/layouts/partials/blocks/templates/image.html b/layouts/partials/blocks/templates/image.html index 2bc4ef56..e09bcf52 100644 --- a/layouts/partials/blocks/templates/image.html +++ b/layouts/partials/blocks/templates/image.html @@ -21,18 +21,21 @@ {{- with .image -}} <figure class="{{ $image_class }}"> - <a class="glightbox" - data-glightbox="type: image;{{ if .credit }}description: {{ partial "PrepareHTML" .credit }}{{ end }}" - href="{{- partial "GetLightboxUrl" . -}}" - title="{{- i18n "commons.lightbox.link.title" -}}" - > - {{ partial "commons/image.html" - (dict - "image" . - "alt" .alt - "sizes" site.Params.image_sizes.blocks.image - )}} - </a> + {{ if not site.Params.image_sizes.design_system.lightbox.disabled }} + <a class="glightbox" + data-glightbox="type: image;{{ if .credit }}description: {{ partial "PrepareHTML" .credit }}{{ end }}" + href="{{- partial "GetLightboxUrl" . -}}" + title="{{- i18n "commons.lightbox.link.title" -}}"> + {{ end }} + {{ partial "commons/image.html" + (dict + "image" . + "alt" .alt + "sizes" site.Params.image_sizes.blocks.image + )}} + {{ if not site.Params.image_sizes.design_system.lightbox.disabled }} + </a> + {{ end }} <figcaption> {{- if $text }} {{ partial "PrepareHTML" $text }} diff --git a/layouts/partials/header/hero.html b/layouts/partials/header/hero.html index b01e3071..14bee13d 100644 --- a/layouts/partials/header/hero.html +++ b/layouts/partials/header/hero.html @@ -22,18 +22,21 @@ {{- end -}} {{- if .image }} <figure> - <a class="glightbox" - data-glightbox="type: image;{{ if .image.credit }}description: {{ partial "PrepareHTML" .image.credit }}{{ end }}" - href="{{ partial "GetLightboxUrl" .image }}" - title="{{- i18n "commons.lightbox.link.title" -}}" - > + {{ if not site.Params.image_sizes.design_system.lightbox.disabled }} + <a class="glightbox" + data-glightbox="type: image;{{ if .image.credit }}description: {{ partial "PrepareHTML" .image.credit }}{{ end }}" + href="{{ partial "GetLightboxUrl" .image }}" + title="{{- i18n "commons.lightbox.link.title" -}}"> + {{ end }} {{ partial "commons/image.html" (dict "image" .image "sizes" ( .sizes | default site.Params.image_sizes.design_system.hero ) "lazy" false ) }} + {{ if not site.Params.image_sizes.design_system.lightbox.disabled }} </a> + {{ end }} {{ if partial "GetTextFromHTML" .image.credit }} <figcaption tabindex="0"> <p> -- GitLab