Refactoring the image loader code so that an early callback for image dimensions is possible