Galleria theme occasionally not loading
Asked Answered
C

6

11

I am using the Galleria slideshow on my site, but I've noticed an error that seems to happen very randomly. Most of the time the slideshow loads correctrly but once in a while I get this error:

 Uncaught Error: Fatal error: Theme at javascript/themes/classic/galleria.classic.js
 could not load, check theme path.

When I reload the page, it's all back to normal. This is the code I'm using to load it:

  <script> 
        // Load the classic theme
   Galleria.loadTheme('javascript/themes/classic/galleria.classic.js');
    </script> 

I have searched around but still haven't found a solution that works. My personal idea was to have a script that keeps loading until it succeeds, since on reload the page works. How would I do this?

Cardamom answered 30/5, 2011 at 22:45 Comment(0)
G
14

1 Try the latest build at gihub: https://github.com/aino/galleria/blob/master/src/galleria.js

2 Try loading the theme using a script tag instead:

<script src="javascript/themes/classic/galleria.classic.js"></script>
Groot answered 1/6, 2011 at 18:5 Comment(0)
A
3

I adopted the method pointed out by David, loading the theme using a script tag:

<script src="javascript/themes/classic/galleria.classic.js"></script>

But was eventually getting another error (Fatal error: Theme CSS could not load after 20 sec). I'd also recommend adding the CSS using a link tag:

<link rel="stylesheet" type="text/css" href="galleria/themes/classic/galleria.classic.css" />
Ansate answered 18/2, 2013 at 14:49 Comment(0)
S
1

I had a similar message today when I tried using Galleria. It happened only in Firefox. What I did to get around it is to add the theme stylesheet link directly in the head. I kept the theme script link in too, after the stylesheet, just in case it was needed. After that, the error message went away and Galleria is working as it should.

Stillmann answered 2/9, 2011 at 5:12 Comment(0)
H
1

Judging from where the error message comes from, and considering the random occurrences, this issue could be from simply hitting the timeout when loading:

Galleria.loadTheme = function( src, options ) {

var loaded = false,
    length = _galleries.length,
    err = window.setTimeout( function() {
        Galleria.raise( "Theme at " + src + " could not load, check theme path.", true );
    }, 5000 );

In version 1.2.2, the timeout is just 2 seconds, in the above (1.2.6) the timeout is 5 seconds. So upgrading to the later version, or customizing the timeout is definitely something to try.

Hedron answered 6/11, 2011 at 15:28 Comment(0)
M
0

Given the random behavior, it feels like a browser bug. More specifically, that the browser looses track of the base URL. I would give the full path from the webroot and see if the error goes away. For example:

Galleria.loadTheme('/gallery/javascript/themes/classic/galleria.classic.js');

If this don't help, try:

try {
    Galleria.loadTheme('javascript/themes/classic/galleria.classic.js');
}
catch(e) {
    location.reload();
}

But this can go infinitely. I would try to get to the bottom of the error and start with different browsers to rule out a bug in your code.

Mytilene answered 30/5, 2011 at 23:0 Comment(3)
I do give it a full path, but i removed it when i posted here. I tried the location.reload() , but still got Uncaught Error: Fatal error: No theme found. j.raisegalleria-1.2.2.min.js:77 j.init.j.theme.object.g.wait.errorgalleria-1.2.2.min.js:42 g.wait.igalleria-1.2.2.min.js:12Cardamom
@Cardamom Did you test different browsers? If it's not a path issue, maybe it's a cache issue. If you can check the webserver logs and see if the file is sent. "No theme found" seems different then "could not load".Mytilene
I don't have access to the logs, sorry. And i've tested it with all browsers. Still happens. The weird thing is on reload it's all fine.Cardamom
L
0

The Beginners Guide states that the script tag in which you load the theme needs to be after the images in the html source. You have probably added the script tag in the head tag. Example from the guide:

<body>
    <div id="galleria">
        <img src="photo1.jpg">
        <img src="photo2.jpg">
        <img src="photo3.jpg">
    </div>
    <script>
        Galleria.loadTheme('galleria/themes/classic/galleria.classic.min.js');
        Galleria.run('#galleria');
    </script>
</body>
Lammergeier answered 23/6, 2013 at 14:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.