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 });
});
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,187건
+
제목 글쓴이 날짜 조회
08-11-25 조회 3,756
08-11-25 조회 2,949
08-11-25 조회 4,526
08-11-25 조회 4,399
08-11-21 조회 4,379
08-11-21 조회 5,309
08-11-20 조회 3,933
08-11-20 조회 3,747
08-11-19 조회 4,017
08-11-19 조회 4,259
08-11-18 조회 4,038
08-11-15 조회 2,916
08-11-14 조회 3,219
08-11-14 조회 2,883
08-11-14 조회 3,279
08-11-13 조회 3,905
08-11-12 조회 1만
08-11-07 조회 4,604
08-11-07 조회 5,591
08-11-03 조회 3,355
08-11-01 조회 5,068
08-11-01 조회 3,019
08-10-30 조회 2,727
08-10-30 조회 3,662
08-10-30 조회 2,759
08-10-30 조회 2,996
08-10-30 조회 2,856
08-10-29 조회 3,941
08-10-29 조회 2,919
08-10-29 조회 2,456
08-10-20 조회 2,582
08-10-18 조회 4,535
08-10-16 조회 3,585
08-10-16 조회 3,392
08-10-14 조회 2,591
08-10-11 조회 3,893
08-10-11 조회 2,491
08-10-09 조회 2,586
08-10-09 조회 2,742
08-10-09 조회 4,211
08-10-08 조회 3,905
08-10-02 조회 3,847
08-10-02 조회 2,595
08-10-02 조회 2,737
08-09-29 조회 4,668
08-09-29 조회 4,300
08-09-26 조회 5,617
08-09-26 조회 3,586
08-09-26 조회 3,652
08-09-26 조회 2,795
08-09-26 조회 3,839
08-09-26 조회 3,578
08-09-26 조회 4,339
08-09-22 조회 3,901
08-09-22 조회 3,085
08-09-22 조회 4,050
08-09-22 조회 3,008
08-09-22 조회 2,660
08-09-21 조회 3,648
08-09-20 조회 4,231
08-09-20 조회 5,500
08-09-20 조회 4,597
08-09-20 조회 2,912
08-09-20 조회 3,319
08-09-20 조회 3,684
08-09-20 조회 3,061
08-09-20 조회 3,250
08-09-20 조회 4,233
08-09-20 조회 3,736
08-09-20 조회 3,316
08-09-19 조회 5,713
08-09-19 조회 4,489
08-09-19 조회 2,801
08-09-18 조회 5,154
08-09-18 조회 4,233
08-09-18 조회 3,606
08-09-18 조회 2,805
08-09-18 조회 3,713
08-09-18 조회 3,508
08-09-17 조회 3,378
08-09-16 조회 3,321
08-09-10 조회 2,534
08-09-09 조회 3,336
08-09-06 조회 4,228
08-09-06 조회 2,780
08-09-06 조회 3,156
08-09-06 조회 2,822
08-09-06 조회 3,048
08-09-06 조회 2,932
08-09-06 조회 2,908
08-09-05 조회 3,909
08-09-05 조회 3,733
08-09-05 조회 3,558
08-09-05 조회 2,780
08-09-05 조회 3,809
08-09-05 조회 5,773
08-09-05 조회 4,225
08-09-05 조회 3,112
08-09-05 조회 3,267
08-09-05 조회 4,690