4,475,600 th visitor since 2017.2.1 ( Today : 6325 )
Programming
No. 824
Name. swindler
Subject. javascript로 이미지 size 측정
Main Cate. Javascript
Sub Cate.
Date. 2021-08-19 18:15
Hit. 713 (121.134.199.74)
File.
<script language=javascript>
$("#logo_image").on('load', function() {
var w = $("#logo_image").width();
var h = $("#logo_image").height();
$("#logo_image_size").html(w + " x " + h);
}).each(function() {
if(this.complete) $(this).load();
});
</script>

그냥 load에서 안 되는 경우가 있어서, 아랫부분이 필요함


아래처럼 처리한 경우도 있음


const img = new Image();
img.onload = function () {
var w = this.width;
var h = this.height;
console.log(w + " X " + h);
if(w != h) {
$("#OriginalImage").show();
}
}
img.src = "<%=sc.get("product.image.url") %><%=image %>";


[바로가기 링크] : http://coolx.net/cboard/develop/824



Name
Password
Comment
Copyright © 1999-2017, swindler. All rights reserved. 367,611 visitor ( 1999.1.8-2004.5.26 ), 2,405,771 ( -2017.01.31)

  2HLAB   2HLAB_Blog   RedToolBox   Omil   Omil_Blog