Created
September 6, 2012 15:07
-
-
Save Neener54/3657151 to your computer and use it in GitHub Desktop.
Get image height before writing to the dom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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