0

Can`t figure out how to call the gif image with a full url (for example: http:// urltoimage .com/test.gif) instead of the stylsheet directory url (obj_test.stylesheet_directory_uri + '/img/ajax-loader.gif').

Any help would be greatly appreciated.

The current code in my custom.js file:

    //infinite scroll
    if ($masonry.length && obj_test.infinitescroll != 'disable') {
    nextSelector = obj_test.nextselector;
    if (document.URL.indexOf('/source/') != -1) {
        nextSelector = '#navigation #navigation-next a';
    }

        $masonry.infinitescroll({
        navSelector : '#navigation',
        nextSelector : nextSelector,
        itemSelector : '.thumb',
        prefill: true,
        bufferPx : 500,
        loading: {
            msgText: '',
            finishedMsg: obj_test.__allitemsloaded,
            img: obj_test.stylesheet_directory_uri + '/img/ajax-loader.gif',
            finished: function() {}
        }

    }, function(newElements) {
        if ($('.check-text01').css('float') == 'left') {
            var $newElems = $(newElements).hide();

            $newElems.imagesLoaded(function() {
                $('#infscr-loading').fadeOut('normal');
                $newElems.show();
                $masonry.masonry('appended', $newElems, true);
            });
        } else {
            var $newElems = $(newElements);
            $('#infscr-loading').fadeOut('normal');
            $masonry.masonry('appended', $newElems, true);
        }
    });
}

Unfortunatly my skills are not enough to solve this problem. I researched (googled) and so on - no luck.

6
  • Why? isn't the method obj_test.stylesheet_directory_uri + '/img/ajax-loader.gif' giving a dynamic and working path to the GIF anyway?
    – Ismail
    Jul 14, 2016 at 20:29
  • This is not my code. In this case it delivers the image from the own content folder of the installation wich gives you more control about the image - you can also deliver it with cdn to. But now i will load the gif from a external source...
    – NewUser
    Jul 14, 2016 at 20:36
  • Sounds like a fix, loading from a CDN and providing full path. Or if you have a child theme where you upload ajax-loader.gif to img/ dir, as obj_test.stylesheet_directory_uri probably points to get_stylesheet_directory_uri() return
    – Ismail
    Jul 14, 2016 at 20:41
  • My Problem is still not solved - if you have any idea, to load the image from a full url - this would be awesome
    – NewUser
    Jul 14, 2016 at 21:26
  • isn't it simple as img: 'https://computerobz.files.wordpress.com/2013/08/when-im-told-that-my-code-is-broken-in-production.gif' in the loading object? did you try such thing?
    – Ismail
    Jul 14, 2016 at 21:29

1 Answer 1

0

Changing

    img: obj_test.stylesheet_directory_uri + '/img/ajax-loader.gif',

to

    img: "http:// urltoimage .com/test.gif",

solve the problem.

Important - the url between '...' does not work! The url must be between "..." That was the problem i dont figured out before :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.