sal0max / grav-plugin-shortcode-gallery-plusplus

A Shortcode extension to add sweet galleries with a lightbox to your Grav website.
MIT License
33 stars 8 forks source link

Getting "Uncaught TypeError: $(...).justifiedGallery is not a function" #39

Closed tdittmar closed 1 year ago

tdittmar commented 1 year ago

I installed the plugin via the admin panel, saved the configuration and cleared all caches.

Before the plugin was installed, I saw the following on my page:

[gallery]<some image markdown>[/gallery]

After installing the plugin, this is gone (conclusion: The plugin is working and detects the shortcode), but I don't see any images. Instead, I get above error in the development console.

The following additional elements are linked in the document and downloaded according to the development console.

Also, the following script is added at the bottom of the page:

<script>
$("#192376910").justifiedGallery({
    rowHeight: 200,
    margins: 3,
    lastRow: "nojustify",
    captions: false,
    border: 0,
    waitThumbnailsLoad: false,
    thumbnailPath: function (currentPath, width, height, image) {
        return image.currentSrc;
    },
});

GLightbox({
    selector: ".glightbox-192376910",
    openEffect: "zoom",
    closeEffect: "zoom",
    slideEffect: "slide",
    closeButton: true,
    touchNavigation: true,
    touchFollowAxis: true,
    keyboardNavigation: true,
    closeOnOutsideClick: true,
    loop: false,
    draggable: true,
    descPosition: "bottom",
    moreText: "See more",
    moreLength: 60,
});
</script>

How can I resolve this issue?

tdittmar commented 1 year ago

Problem was that my theme was also including jquery at the end of the page, so the second instance was used instead of the instance that the plugin was working on.

For anyone running into this issue: Check that if your theme uses jquery, it is embedded as

{% do assets.addJs('jquery', 101) %}