Adjust image preload dynamically

JH's Avatar

JH

29 Jun, 2014 02:25 PM

Hi,

Thanks for a great tool.

Is it possible to modify parameter numImagesToPreload dynamically or in any other way to adjust the preloading dynamically? I have several sliders on one page and want to load just the first image for the sliders which are near the bottom of the page (with numImagesToPreload = 0), but increase the preload once the user starts clicking through these sliders.

Regards

  1. Support Staff 1 Posted by Dmitry Semenov on 29 Jun, 2014 05:33 PM

    Dmitry Semenov's Avatar

    Hi,

    You can change this option dynamically, but you may add blank slides (e.g. with empty divs), and them append content inside them when you need, here is how to loop through slides:

    var slider = $('.royalSlider').data('royalSlider').
    for(var i = 0; i < slider.numSlides; i++) {
        var someContent = $("<div>some content with some image<img src="img.jpg" /></div>");
        var slide = slider.slides[i];
    
        slide.content = someContent;
        if(slide.holder) { slide.holder.html( someContent ); }
    
    }
    
  2. 2 Posted by Vicente Martins on 03 Jul, 2019 02:13 PM

    Vicente Martins's Avatar

    Hi Dmitry,

    You said above that it is possible to change this option dynamically. But I'm executing slider.st.numImagesToPreload = 10; and looks like the slider continues to use the initial setting.

    Am I doing anything wrong? What should I do differently?

    Thanks

  3. Support Staff 3 Posted by Dmitry Semenov on 03 Jul, 2019 03:14 PM

    Dmitry Semenov's Avatar

    This functionality was modified since the previous comment. If you're using unminified or unmangled version - you may call method slider._refreshNumPreloadImages() after the option is modified.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac