run javascript after image is lazyloaded

lukasildza's Avatar


11 Nov, 2017 02:50 PM

Im using slider with lazyload enabled here -
To make images always fill the screen and keep aspect ratio, im using this script lower, to check if the windows aspect ratio is wider or narrower than particular image, and then add a class accordingly. Problem is, that it only works for images which are loaded on the beginning.
Could you please help me, how to fire this script also when new image is added? i believe it is documented but i cant really use it. Im not a coder. Would be much appreciated :)

$j(window).load(function() {
function resizeBg() {

    if ( ($j(window).width() / $j(window).height()) < $j("body.home img.rsImg").width() / $j("body.home img.rsImg").height()) {
        $j("body.home img.rsImg")
    } else {
        $j("body.home img.rsImg")



  1. Support Staff 1 Posted by Dmitry Semenov on 11 Nov, 2017 05:24 PM

    Dmitry Semenov's Avatar


    You may use rsAfterContentSet event

    But I wonder why you don't want to just use fill scale mode


  2. 2 Posted by lukasildza on 12 Nov, 2017 07:56 AM

    lukasildza's Avatar

    thanks for quick help. For some reason, when i tried fill scale mode with centering earlier, it was not working as expected. Tried to disable my .js code now and enable it, and it's working like a charm.


  3. lukasildza closed this discussion on 12 Nov, 2017 12:16 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? 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