blueswen / mkdocs-glightbox

A MkDocs plugin supports image lightbox (zoom effect) with GLightbox.
https://blueswen.github.io/mkdocs-glightbox/
MIT License
115 stars 14 forks source link

glightbox is breaking if the privacy plugin is set. #36

Open divSelector opened 3 months ago

divSelector commented 3 months ago
plugins:

  - glightbox:
      touchNavigation: true
      loop: false
      effect: zoom
      slide_effect: slide
      width: 100%
      height: auto
      zoomable: true
      draggable: true
      skip_classes:
        - glightbox-thumb
      auto_caption: false
      caption_position: bottom
      background: white
      shadow: true

  - privacy

it will work if I comment out the privacy bit.

Specifically the error it throws is

   Uncaught TypeError: element.querySelector(...) is null
    <anonymous> (index):1066
    <anonymous> (index):1065
    RxJS 7
    No index.ts:44
    RxJS 10
    No index.ts:44
    <anonymous> bundle.ts:133
    <anonymous> bundle.ts:318

The offending code it links to is around here var imgSrc = element.querySelector('img').src;

<script>document$.subscribe(() => {document.querySelectorAll('.glightbox').forEach(function(element) {
    var imgSrc = element.querySelector('img').src;
    element.setAttribute('href', imgSrc);
});
const lightbox = GLightbox({"touchNavigation": true, "loop": false, "zoomable": true, "draggable": true, "openEffect": "zoom", "closeEffect": "zoom", "slideEffect": "slide"});})</script><script>
var livereload = function(epoch, requestId) {
    var req = new XMLHttpRequest();
    req.onloadend = function() {

I'm just going to turn off privacy for now but I wonder why it does that.

blueswen commented 2 months ago

This bug is fixed on v0.4.0. Please let me know if the error message is still showing up.