Skip to content

Commit

Permalink
Modify width and height position
Browse files Browse the repository at this point in the history
  • Loading branch information
blueswen committed Sep 29, 2022
1 parent 75d051c commit 346a9f0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mkdocs_glightbox/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def on_post_page(self, output, page, config, **kwargs):

js_code = soup.new_tag("script")
plugin_config = dict(self.config)
lb_config = {k: plugin_config[k] for k in ["touchNavigation", "loop", "width", "height", "zoomable", "draggable"]}
lb_config = {k: plugin_config[k] for k in ["touchNavigation", "loop", "zoomable", "draggable"]}
lb_config['openEffect'] = plugin_config.get('effect', 'zoom')
lb_config['closeEffect'] = plugin_config.get('effect', 'zoom')
js_code.string = f"const lightbox = GLightbox({json.dumps(lb_config)});"
Expand All @@ -67,6 +67,7 @@ def on_page_content(self, html, page, config, **kwargs):
# skip page with meta glightbox is false
if "glightbox" in page.meta and page.meta.get('glightbox', True) is False:
return html
plugin_config = {k: dict(self.config)[k] for k in ["width", "height"]}
# skip emoji img with index as class name from pymdownx.emoji https://facelessuser.github.io/pymdown-extensions/extensions/emoji/
skip_class = ["emojione", "twemoji", "gemoji"]
# skip image with off-glb class
Expand All @@ -79,6 +80,8 @@ def on_page_content(self, html, page, config, **kwargs):
a = soup.new_tag("a")
a["class"] = "glightbox"
a["href"] = img.get("src", "")
for k, v in plugin_config.items():
a[f"data-{k}"] = v
img.wrap(a)
return str(soup)

Expand Down

0 comments on commit 346a9f0

Please sign in to comment.