trying to get dimenstions (e.g. 600x300) from an image using javascript. I am not sure how to return the data because it's not working. Do I need a callback, and how ?
<script>
function getMeta(url){
var img = new Image();
var res = img.onload = function(){
var ret = this.width+'x'+ this.height;
alert(ret);
return ret;
};
img.src = url;
return res;
}
var meta = getMeta('https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg');
alert(meta);
</script>