From 273dd2313ac30a73577234071e7336f625bfc2fb Mon Sep 17 00:00:00 2001 From: Martin Donath Date: Fri, 1 May 2026 17:37:02 +0200 Subject: [PATCH] fix: auto-themed gallery takes precedence over explicit grouping Signed-off-by: squidfunk --- python/zensical/extensions/glightbox.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/python/zensical/extensions/glightbox.py b/python/zensical/extensions/glightbox.py index 6eda31a..f7a84dd 100644 --- a/python/zensical/extensions/glightbox.py +++ b/python/zensical/extensions/glightbox.py @@ -163,10 +163,14 @@ class GlightboxTreeprocessor(TreeprocessorExt): # Return element return el - def _resolve_gallery(self, img: Element) -> str: + def _resolve_gallery(self, img: Element) -> str | None: """Determine gallery group for an image.""" src = img.get("data-src") or img.get("src") or "" + # Explicit gallery grouping takes precedence over auto-themed grouping + if gallery := img.get("data-gallery"): + return gallery + # If auto-themed grouping is enabled, group images by light/dark mode # hints in the URL (e.g. from GitHub's light/dark mode image syntax) if self.config.auto_themed: @@ -175,8 +179,8 @@ class GlightboxTreeprocessor(TreeprocessorExt): if "#only-dark" in src or "#gh-dark-mode-only" in src: return "dark" - # Explicit gallery grouping takes precedence over auto-themed grouping - return img.get("data-gallery") or "" + # No gallery grouping + return None def _find_parent(self, root: Element, target: Element) -> Element | None: """Return the direct parent of target within the element tree."""