Jquery从图像URL计算图像的宽度和高度

Kam*_*ran 3 jquery image

我试图使用javascript和jquery从图像的地址/ URL找出图像的宽度和高度.

有谁知道我怎么做到这一点?提前致谢.

Sam*_*tin 11

要做到这一点,身体没有任何东西,请尝试以下方法:

var imgURL = 'http://www.gravatar.com/avatar/f77ef279d6b33bc09ce5422049dd9e37?s=32&d=identicon&r=PG';
var img = $('<img src="'+imgURL+'"/>').load(function(){
    console.log(this.width + ' x ' + this.height);
});
Run Code Online (Sandbox Code Playgroud)