mirror of
https://github.com/zensical/zensical.git
synced 2026-05-03 01:20:33 +00:00
fix: remove img attributes moved to parent in GLightboxExtension
Signed-off-by: squidfunk <martin.donath@squidfunk.com>
This commit is contained in:
@@ -84,11 +84,11 @@ class GlightboxTreeprocessor(Treeprocessor):
|
||||
return
|
||||
|
||||
# Wrap image with anchor
|
||||
idx = list(parent).index(img)
|
||||
index = list(parent).index(img)
|
||||
el = self._build_anchor(img)
|
||||
parent.remove(img)
|
||||
el.append(img)
|
||||
parent.insert(idx, el)
|
||||
parent.insert(index, el)
|
||||
|
||||
def _build_anchor(self, img: Element) -> Element:
|
||||
"""Construct the anchor from image attributes."""
|
||||
@@ -126,6 +126,19 @@ class GlightboxTreeprocessor(Treeprocessor):
|
||||
if gallery := self._resolve_gallery(img):
|
||||
el.set("data-gallery", gallery)
|
||||
|
||||
# Remove sourced attributes from img now that they live on the anchor
|
||||
for attr in (
|
||||
"data-width",
|
||||
"data-height",
|
||||
"data-src",
|
||||
"data-title",
|
||||
"data-description",
|
||||
"data-caption-position",
|
||||
"data-gallery",
|
||||
):
|
||||
if attr in img.attrib:
|
||||
img.attrib.pop(attr)
|
||||
|
||||
# Return element
|
||||
return el
|
||||
|
||||
|
||||
Reference in New Issue
Block a user