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

Timestamp added with image URL for reloading in case of error on first load #285

Open
Zahid-BS23 opened this issue Mar 6, 2013 · 1 comment

Comments

@Zahid-BS23
Copy link

It seems like, in case of any error, Galleria retries to load images with a time stamp added with the image URL. Following code is from Galleria.Picture.load

onerror = function() {
    if ( !reload ) {
        reload = true;
        // reload the image with a timestamp
        window.setTimeout((function(image, src) {
            return function() {
                image.attr('src', src + '?' + Utils.timestamp() );
            };
        }( $(this), src )), 50);
    } else {
        // apply the dummy image if it exists
        if ( DUMMY ) {
            $( this ).attr( 'src', DUMMY );
        } else {
            Galleria.raise('Image not found: ' + src);
        }
    }
}

This is fine but the function which adds time stamp with the image URL will cause problem if query strings are already there in the URL.

window.setTimeout((function(image, src) {
    return function() {
        image.attr('src', src + '?' + Utils.timestamp() );
    };
}( $(this), src )), 50);

For example if the image URL is like "....../image1.jpg?width=600&height=400" then, on error while loading the image first time, Galleria will add time stamp with the URL and the new URL will be an invalid one "....../image1.jpg?width=600&height=400?xxxxxxxxxxxxx"

It would be great if the Question (?) is added only if no query string is already there in the URL. In additions, I guess it will be better to add the time stamp with a query string name to form URL like.

"....../image1.jpg?width=600&height=400&ts=xxxxxxxxxxxxx"
or
"....../image1.jpg?ts=xxxxxxxxxxxxx"

@andreynovikov
Copy link

It should be configurable anyway, because I use ; instead of & for query string parameter separation.

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

2 participants