Created
May 9, 2013 20:17
-
-
Save lushone/5550239 to your computer and use it in GitHub Desktop.
get an image's dimensions using pure js
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
/** | |
* get an image's dimensions using pure js | |
*/ | |
var img = new Image(); | |
img.onload = function() { | |
document.write('<strong>image:</strong> ' + this.src + '<br><strong>width:</strong> '+ this.width + '<br><strong>Height:</strong> ' + this.height); | |
} | |
img.src = 'http://domain.com/image.jpg'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment