Created
November 2, 2014 06:09
-
-
Save chrisciampoli/35c1228708cdb83513e0 to your computer and use it in GitHub Desktop.
Get image sizes from meta
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
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