Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: gallery.justifiedGallery is not a function #66

Closed
vtomyev opened this issue Jan 1, 2024 · 12 comments
Closed

Uncaught TypeError: gallery.justifiedGallery is not a function #66

vtomyev opened this issue Jan 1, 2024 · 12 comments
Assignees

Comments

@vtomyev
Copy link

vtomyev commented Jan 1, 2024

I installed the shortcode using hugo modules. When I attempt to run the shortcode nothing shows up on the screen. To be fair im a bit new to this.

Here is the error I see in the console
Screenshot from 2023-12-31 20-22-49

This is he HTML that loads. I can see the picture there.
Screenshot from 2023-12-31 20-23-21

The gallery is supposed to be between the heading and the social media buttons.
Screenshot from 2023-12-31 20-23-36

Can anyone please help me?

@mfg92
Copy link
Owner

mfg92 commented Jan 3, 2024

Can you show how you included the gallery into your markdown file?
Also, please check your browser's devtools network tab to see if all files are loading successfully. The error you are experiencing may indicate that the Justified-Gallery JS could not be loaded.

@mfg92 mfg92 self-assigned this Jan 3, 2024
@vtomyev
Copy link
Author

vtomyev commented Jan 7, 2024

Thank you for taking the time out of your day to help me with this!
Here is how I'm using the shortcode in my markdown:
image


This is my network tab in the browser when I try to load the gallery page:
image

@mfg92
Copy link
Owner

mfg92 commented Jan 8, 2024

There are two versions of jQuery loaded on your page, one from hugo-shortcode-gallery (jquery-3.7.1.min.js) and another, probably from your theme (jquery.min.js). Having two versions of jQuery in parallel will lead to errors. You can tell hugo-shortcode-gallery not to load it's own jQuery, but to use the jQuery provided by your theme. To do this, simply remove the loadJQuery parameter from the shortcode.

@rhizoet
Copy link

rhizoet commented Jan 21, 2024

I have the same problem. I'm using the universal theme and the latest hugo version.

I've included it with the following shortcode
{{< gallery match="images/*" sortOrder="asc" rowHeight="150" margins="5" thumbnailResizeOptions="500x500 q90 Lanczos" showExif=false previewType="blur" embedPreview=true loadJQuery=true >}}

All resources load correctly (take a look at screenshot) and only in Console I see

Uncaught TypeError: gallery.justifiedGallery is not a function
    at HTMLDocument.<anonymous> (impressionen/:2748:11)
    at e (jquery-3.7.1.min.js:2:27028)
    at t (jquery-3.7.1.min.js:2:27330)

I don't know what to do. Do you have an hint for me?

Bildschirmfoto_2024-01-21_18-29-34

@mfg92
Copy link
Owner

mfg92 commented Jan 21, 2024

@rhizoet Have you tried removing loadJQuery=true from the shortcode?

@rhizoet
Copy link

rhizoet commented Jan 21, 2024

Yes, I've tried. But then I get
Uncaught ReferenceError: jQuery is not defined.

So I think I must enable jQuery.

@vtomyev
Copy link
Author

vtomyev commented Jan 21, 2024 via email

mfg92 added a commit that referenced this issue Jan 22, 2024
@mfg92
Copy link
Owner

mfg92 commented Jan 22, 2024

@rhizoet & @vtomyev:

This is most likely due to your website/theme loading a second instance of jQuery after the gallery has been partially initialised.

I have implemented something that should prevent the gallery from breaking in such cases, its on the jquery-loading-robustness branch. Together with loadJQuery=true this should solve your problem. Please try it and let me know if it works.

@rhizoet
Copy link

rhizoet commented Jan 23, 2024

@mfg92 Thank you very much for your hard work. It works perfectly on my sites.

@vtomyev
Copy link
Author

vtomyev commented Jan 23, 2024

Hey, I'm sorry to be bugging you with this. Mine still is not working...
Now I'm getting this error:
image

@mfg92
Copy link
Owner

mfg92 commented Jan 25, 2024

Hey, I'm sorry to be bugging you with this. Mine still is not working... Now I'm getting this error:

Are you sure you have checked out the jquery-loading-robustness branch?
If you have, and you are still getting this exception, I need more information. Best would be a ZIP or github repository containing a minimal example of a complete hugo project where this problem occurs.

mfg92 added a commit that referenced this issue Feb 12, 2024
mfg92 added a commit that referenced this issue Feb 12, 2024
@mfg92
Copy link
Owner

mfg92 commented Feb 12, 2024

@rhizoet I have merged the changes into main, thank you for testing.

@vtomyev I will close this issue as I have not heard from you, if you still have problems please open a new issue with a minimal sample project that shows your problem.

@mfg92 mfg92 closed this as completed Feb 12, 2024
alexvanderberkel pushed a commit to alexvanderberkel/hugo-shortcode-gallery that referenced this issue Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants