Skip to content

Instantly share code, notes, and snippets.

@Neener54
Created September 6, 2012 15:07
Show Gist options
  • Save Neener54/3657151 to your computer and use it in GitHub Desktop.
Save Neener54/3657151 to your computer and use it in GitHub Desktop.
Get image height before writing to the dom
img_call = function(url){
$('<img />').attr('src', url).load(function(){console.log(this.width); console.log(this.height);});
};
// Image Dimension return version
img_attr = function(url){
var img_attributes = {};
$('<img />').attr('src', url).load(function(){
img_attributes.width = this.width;
img_attributes.height = this.height;
img_attributes.src = url;
});
return img_attributes;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment