function resizeImage(image, max) {
    if (Math.max(image.width, image.height) > max) {
        if (image.width > image.height) image.width = max;
        else image.height = max; 
    }
    return true;
}

  

<img onload="var max=64;if(Math.max(this.width,this.height)>max){if(this.width>this.height)this.width=max;else this.height=max;}" src="/test.jpg" />

或者

<img onload="return resizeImage(this,64)" src="/test.jpg" />

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-03
  • 2022-01-15
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-12
  • 2022-12-23
相关资源
相似解决方案