리사이즈에 대해 질문합니다. > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

리사이즈에 대해 질문합니다. 정보

리사이즈에 대해 질문합니다.

본문

가로 세로를 설정하여 설정된 값 이상으로 이미지를 늘어나지 않게 하려면 어떻게 수정해야 할까요?
아래 링크와 같은 형식처럼요. ^^
 
 
아래 스크립트는 가로 200 이상으로 늘어나지 않습니다.
세로도 설정하려니 방법을 모르겠습니다. ^^
답변 부탁드립니다.
<img src='URL' name='target_resize_image[]'>
 
<script language="JavaScript">
// HTML 로 넘어온 <img ... > 태그의 폭이 테이블폭보다 크다면 테이블폭을 적용한다.
function resize_image()
{
    var target = document.getElementsByName('target_resize_image[]');
    var image_width = parseInt('200');
    var image_height = 0;
    for(i=0; i<target.length; i++) {
        // 원래 사이즈를 저장해 놓는다
        target[i].tmp_width  = target[i].width;
        target[i].tmp_height = target[i].height;
        // 이미지 폭이 테이블 폭보다 크다면 테이블폭에 맞춘다
        if(target[i].width > image_width) {
            image_height = parseFloat(target[i].width / target[i].height)
            target[i].width = image_width;
            target[i].height = parseInt(image_width / image_height);
        }
    }
}
window.onload = resize_image;
</script>

댓글 전체

if(target[i].width > image_width) {
            image_height = parseFloat(target[i].width / target[i].height)
            target[i].width = image_width;
            target[i].height = parseInt(image_width / image_height);
        }
}

============== 위 부분을 아래 부분처럼 해 보세요. ==========================

if( target[i].width > target[i].height)
    if(target[i].width > image_width) {
          target[i].width = image_width;
          //target[i].height = "";
} else {
    if(target[i].height > image_height ) {
          target[i].height = image_height ;
          //target[i].width = "";
}
===============================================================
//를 없애보기도 하세요
전체 136 |RSS
그누4 질문답변 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT