From 50bc1809806a55ed10de6f3cd2af6a0f96b58f57 Mon Sep 17 00:00:00 2001 From: Michal Fapso Date: Wed, 31 Jan 2024 23:23:57 +0100 Subject: [PATCH] added "manual" option --- README.md | 2 ++ demo-mkdocs/docs/index.md | 2 ++ mkdocs_glightbox/plugin.py | 3 ++- schema.json | 6 ++++++ tests/fixtures/mkdocs-options.yml | 1 + 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1e8e3b1..80a7405 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ GLightbox is a pure javascript lightbox library with mobile support. caption_position: bottom background: white shadow: true + manual: false ``` | Option | Default | Description | @@ -70,6 +71,7 @@ GLightbox is a pure javascript lightbox library with mobile support. | caption_position | bottom | Default captions position. (bottom, top, left, right) | | background | white | The background CSS of lightbox image. The background will shown when the image is transparent. You can use any CSS value for the background for example `#74b9ff` or `Gainsboro` or `none` for nothing. | | shadow | true | Enable or disable the shadow of lightbox image. Disable it when the background is `none` to prevent shadow around the transparent image. | + | manual | false | When true, lightbox has to be enabled for each image manually by adding 'on-glb' class to it. | Check more options information on [GLightbox Docs](https://github.com/biati-digital/glightbox#lightbox-options). diff --git a/demo-mkdocs/docs/index.md b/demo-mkdocs/docs/index.md index 1fb5ef6..5b5df50 100644 --- a/demo-mkdocs/docs/index.md +++ b/demo-mkdocs/docs/index.md @@ -51,6 +51,7 @@ GLightbox is a pure javascript lightbox library with mobile support. caption_position: bottom background: white shadow: true + manual: false ``` | Option | Default | Description | @@ -68,6 +69,7 @@ GLightbox is a pure javascript lightbox library with mobile support. | caption_position | bottom | Default captions position. (bottom, top, left, right) | | background | white | The background CSS of lightbox image. The background will shown when the image is transparent. You can use any CSS value for the background for example `#74b9ff` or `Gainsboro` or `none` for nothing. | | shadow | true | Enable or disable the shadow of lightbox image. Disable it when the background is `none` to prevent shadow around the transparent image. | + | manual | false | When true, lightbox has to be enabled for each image manually by adding 'on-glb' class to it. | Check more options information on [GLightbox Docs](https://github.com/biati-digital/glightbox#lightbox-options). diff --git a/mkdocs_glightbox/plugin.py b/mkdocs_glightbox/plugin.py index 5da1385..d997238 100644 --- a/mkdocs_glightbox/plugin.py +++ b/mkdocs_glightbox/plugin.py @@ -34,6 +34,7 @@ class LightboxPlugin(BasePlugin): ), ("background", config_options.Type(str, default="white")), ("shadow", config_options.Type(bool, default=True)), + ("manual", config_options.Type(bool, default=False)), ) def on_config(self, config): @@ -146,7 +147,7 @@ def wrap_img_with_anchor(self, match, plugin_config, skip_class, meta): classes = re.findall(r'class="([^"]+)"', img_attr) classes = [c for match in classes for c in match.split()] - if meta.get("glightbox-manual", False): + if meta.get("glightbox-manual", False) or self.config["manual"]: if "on-glb" not in classes: return img_tag else: diff --git a/schema.json b/schema.json index 5f58985..a96d31d 100644 --- a/schema.json +++ b/schema.json @@ -104,6 +104,12 @@ "markdownDescription": "https://blueswen.github.io/mkdocs-glightbox/#usage", "type": "boolean", "default": true + }, + "manual": { + "title": "When true, lightbox has to be enabled for each image manually by adding 'on-glb' class to it", + "markdownDescription": "https://blueswen.github.io/mkdocs-glightbox/#usage", + "type": "boolean", + "default": false } }, "additionalProperties": false diff --git a/tests/fixtures/mkdocs-options.yml b/tests/fixtures/mkdocs-options.yml index 8ab2809..1ea7282 100644 --- a/tests/fixtures/mkdocs-options.yml +++ b/tests/fixtures/mkdocs-options.yml @@ -15,3 +15,4 @@ plugins: auto_caption: true background: none shadow: false + manual: false