Skip to content

Instantly share code, notes, and snippets.

@chrisciampoli
Created November 2, 2014 06:09
Show Gist options
  • Save chrisciampoli/35c1228708cdb83513e0 to your computer and use it in GitHub Desktop.
Save chrisciampoli/35c1228708cdb83513e0 to your computer and use it in GitHub Desktop.
Get image sizes from meta
function getMeta(url, fn) {
var sizes = {};
$('<img />').attr("src", url).load(function() {
var dims = {
w: this.width,
h: this.height
};
$(this).trigger({
type: "imgLoaded",
height: dims.h,
width: dims.w
});
}).on('imgLoaded', function(event) {
sizes = event;
window.t1 = sizes;
fn = fn || function() {};
fn(sizes);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment