I am attempting to manipulate image dimensions before rendering the images in the DOM. I am getting the image src paths from a data feed that contains these paths. The path point to different servers who host there product images. For example: src: http://pathstoclientserver.jpg.
I am attempting to construct the images as follows:
pandora.LayoutCtrl.prototype.constructImageElements = function() {
var width = 0;
var height = 0;
for (var i = 0; i < this.imagesSrc.length; i++) {
var image = new Image();
image.src = this.imagesSrc[i];
width = image.width;
height = image.height;
this.images.push(image);
}
};
I was thinking that the image width would be available but since it comes back as zero, I am guessing the DOM must render the image before that property is available. Is that true? Also, if that is true, does anyone know of a way to get this images dimensions before rendering them in the DOM?