R

이미지 리사이즈 jQuery 로 변경 방법

board.js 파일에 아래 항목을 추가 해주세요.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jQuery.resimg = function(element, options){
    var setting = { imageWidth:600, borderColor:false }
    $.extend(setting, options);

    var imageWidth = setting.imageWidth;
    var borderColor = setting.borderColor;


    $(element).each(function(){
var img_width = $(this).outerWidth();
    var img_height = $(this).outerHeight();

//원래 사이즈를 저장한다.
    $(this).attr("tmp_width", img_width);
    $(this).attr("tmp_height", img_height);

    // 이미지 폭이 테이블 폭보다 크다면 테이블폭에 맞춘다
    if(img_width > imageWidth) {
        imageHeight = parseFloat(img_width/ img_height);
        $(this).width(imageWidth).height(parseInt(imageWidth / imageHeight)).css("cursor", "pointer");
//$(this).width(imageWidth).css("cursor", "pointer");
    }

    if (borderColor) $(this).css({ "border" : "1px solid "+ borderColor });
});
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

그리고 view스킨 파일 최하단스크립트를 아래와 같이 수정하세요.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//제이쿼리 임포트
<script language="JavaScript" src="<?="$g4[path]/js/jquery-latest.js"></script>
<script language="JavaScript" src="<?="$g4[path]/js/board.js"?>"></script>
<script language="JavaScript">
$(document).ready(function(){
    $.resimg("img[name='target_resize_image[]']", {imageWidth:<?=(int)$board[bo_image_width]?>});
//resizeBoardImage(<?=(int)$board[bo_image_width]?>);
    drawFont();
});
</script>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[이 게시물은 관리자님에 의해 2011-10-31 16:55:28 jQuery에서 이동 됨]
|

댓글 1개

파폭에서 이미지 팝업 띄울시 에러가 있어 약간의 코드를 수정했습니다.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jQuery.resimg = function(element, options){
var setting = { imageWidth:600, borderColor:false }
$.extend(setting, options);

var imageWidth = setting.imageWidth;
var borderColor = setting.borderColor;

//alert($(element).children().get().length);
$(element).each(function(){
var img_width = $(this).outerWidth();
var img_height = $(this).outerHeight();

//원래 사이즈를 저장한다.
//$(this).attr("tmp_width", img_width);
//$(this).attr("tmp_height", img_height);
var i = $(element).index($(this));
$(element)[i].tmp_width = img_width;
$(element)[i].tmp_height = img_height;

// 이미지 폭이 테이블 폭보다 크다면 테이블폭에 맞춘다
if(img_width > imageWidth) {
imageHeight = parseFloat(img_width/ img_height);
$(this).width(imageWidth).height(parseInt(imageWidth / imageHeight)).css("cursor", "pointer");
//$(this).width(imageWidth).css("cursor", "pointer");
}

if (borderColor) $(this).css({ "border" : "1px solid "+ borderColor });
});
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
16년 전 조회 1,142
16년 전 조회 2,096
16년 전 조회 2,070
16년 전 조회 1,603
16년 전 조회 2,141
16년 전 조회 2,368
16년 전 조회 1,482
16년 전 조회 1,832
16년 전 조회 2,011
16년 전 조회 1,108
16년 전 조회 1,786
16년 전 조회 1,494
16년 전 조회 1,999
16년 전 조회 1,407
16년 전 조회 2,297
16년 전 조회 1,989
16년 전 조회 5,968
16년 전 조회 2,005
16년 전 조회 3,780
16년 전 조회 1,553
16년 전 조회 1,840
16년 전 조회 2,166
16년 전 조회 2,704
16년 전 조회 2,404
16년 전 조회 2,837
16년 전 조회 3,083
16년 전 조회 3,104
16년 전 조회 1,903
16년 전 조회 1,632
16년 전 조회 1,492
16년 전 조회 1,812
16년 전 조회 1,294
16년 전 조회 2,062
16년 전 조회 1,831
17년 전 조회 1,700
17년 전 조회 1,386
17년 전 조회 2,265
17년 전 조회 3,322
17년 전 조회 2,243
17년 전 조회 1,828
17년 전 조회 1,601
17년 전 조회 2,133
17년 전 조회 4,813
17년 전 조회 1,507
17년 전 조회 2,244
17년 전 조회 2,221
17년 전 조회 2,499
17년 전 조회 2,233
17년 전 조회 4,535
17년 전 조회 3,028
17년 전 조회 2,960
17년 전 조회 1,678
17년 전 조회 1,324
17년 전 조회 4,051
17년 전 조회 1,711
17년 전 조회 1,713
17년 전 조회 2,212
17년 전 조회 1,973
17년 전 조회 1,599
17년 전 조회 4,018
17년 전 조회 1,849
17년 전 조회 3,215
17년 전 조회 3,107
17년 전 조회 1,125
17년 전 조회 1,941
17년 전 조회 1,699
17년 전 조회 1,946
17년 전 조회 2,730
17년 전 조회 3,118
17년 전 조회 3,309
17년 전 조회 3,423
17년 전 조회 1,555
17년 전 조회 1,515
17년 전 조회 2,339
17년 전 조회 2,070
17년 전 조회 2,381
17년 전 조회 2,907
17년 전 조회 3,361
17년 전 조회 2,458
17년 전 조회 1,728
17년 전 조회 3,302
17년 전 조회 3,158
17년 전 조회 3,138
17년 전 조회 4,010
17년 전 조회 2,674
17년 전 조회 2,494
17년 전 조회 2,743
17년 전 조회 2,987
17년 전 조회 2,698
17년 전 조회 1,539
17년 전 조회 1,977
17년 전 조회 1,572
17년 전 조회 2,000
17년 전 조회 2,608
17년 전 조회 8,780
17년 전 조회 3,254
17년 전 조회 4,333
17년 전 조회 2,076
17년 전 조회 3,752
17년 전 조회 1,650