이미지 파일 자동으로 줄일때요. > 그누4 질문답변

그누4 질문답변

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

이미지 파일 자동으로 줄일때요. 정보

이미지 파일 자동으로 줄일때요.

본문

<script language="JavaScript">
function resizeBoardImage(imageWidth, borderColor) {

    var target = document.getElementsByName('target_resize_image[]');
    var imageHeight = 0;

    if (target) {
        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 > imageWidth) {
                imageHeight = parseFloat(target[i].width / target[i].height)
                target[i].width = imageWidth;
                target[i].height = parseInt(imageWidth / imageHeight);
                target[i].style.cursor = '';

                // 스타일에 적용된 이미지의 폭과 높이를 삭제한다
                target[i].style.width = '';
                target[i].style.height = '';
            }

            if (borderColor) {
                target[i].style.borderWidth = '1px';
                target[i].style.borderStyle = 'solid';
                target[i].style.borderColor = borderColor;
            }
        }
    }
}

</script>
<? $content_table_width= $right_table_width-20; ?>
<script type="text/javascript">
try { window.attachEvent("onload", boardImageResize); }
catch (e) { window.addEventListener("load", boardImageResize, false); }
function boardImageResize() {
    resizeBoardImage(<?=(int)$content_table_width?>);
}
</script>


이미지 파일을 자동으로 줄일때 그누보드에서 위와 같은 태그를 사용합니다.

이게잘 작동하는데요.

문제는 아래처럼 레이어 속성이 none으로 보이지않으면 이미지가 줄어들지 않는다는 겁니다.
<div style='display:none;'>
<IMG border=0 name=target_resize_image[] src="http://www.xxxxx.com/1346833694.jpg">
</div>

어떻게 하면 줄어들게 할수있을까요?

고수님들의 고견 부탁드립니다.
  • 복사

댓글 전체

© SIRSOFT
현재 페이지 제일 처음으로