I’m loading around 50 images from json data returned from PHP. To avoid the extra call of PHP getting the image size I’d like to do this on the client side. Is this possible?
Here’s my current jquery call to build the image list:
// Create HTML for the images.
var html = '';
$.each(data.profiles, function() {
// Can I determine the img height or do I need to wait until the image is loaded?
html += '<a href="/view_profile.php?id='+this.user_id+'">';
html += '<img src="'+this.file_name+'" width="200" height="" style="border:0;">';
html += '</a><br>';
});
You could bind the load event of the image and get it when the client loads the image like this: