Created
March 26, 2012 21:40
-
-
Save johan/2209957 to your computer and use it in GitHub Desktop.
Revisions
-
johan created this gist
Mar 26, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ // jQuery.naturalWidth / jQuery.naturalHeight plugin for (already-loaded) images // Triple-licensed: Public Domain, MIT and WTFPL license - share and enjoy! (function($) { function img(url) { var i = new Image; i.src = url; return i; } if ('naturalWidth' in (new Image)) { $.fn.naturalWidth = function() { return this[0].naturalWidth; }; $.fn.naturalHeight = function() { return this[0].naturalHeight; }; return; } $.fn.naturalWidth = function() { return img(this.src).width; }; $.fn.naturalHeight = function() { return img(this.src).height; }; })(jQuery);