self.options.onImageSwap(self.$elem); newImg.onload = function() { self.largeWidth = newImg.width; self.largeHeight = newImg.height; self.zoomImage = largeimage; self.zoomWindow.css({ "background-size": self.largeWidth + 'px' + self.largeHeight + 'px' }); self.swapAction(smallimage, largeimage); return; }