Skip to content

Instantly share code, notes, and snippets.

@d-tux
Created February 6, 2015 14:52
Show Gist options
  • Select an option

  • Save d-tux/7d56be2464262b7c7d21 to your computer and use it in GitHub Desktop.

Select an option

Save d-tux/7d56be2464262b7c7d21 to your computer and use it in GitHub Desktop.
Finds the "real" size on an image.
function getImageSize(img) {
var i = $('<img/>')
.css('visibility', 'hidden')
.attr('src', $(img).attr('src'))
.appendTo('body');
var r = {
width: i.width()
, height: i.height()
};
i.remove();
return r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment