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-04-03 조회 2,804
08-04-02 조회 3,003
08-04-02 조회 2,879
08-04-02 조회 3,195
08-04-02 조회 3,153
08-04-02 조회 3,178
08-04-02 조회 3,125
08-04-02 조회 2,833
08-04-02 조회 2,827
08-04-02 조회 2,932
08-04-02 조회 3,235
08-04-02 조회 3,133
08-04-02 조회 2,911
08-04-02 조회 3,048
08-04-02 조회 2,718
08-04-02 조회 2,973
08-04-02 조회 3,297
08-04-02 조회 4,093
08-04-02 조회 3,288
08-03-31 조회 2,583
08-03-31 조회 3,147
08-03-31 조회 3,656
08-03-29 조회 2,775
08-03-28 조회 3,481
08-03-28 조회 2,981
08-03-28 조회 2,644
08-03-27 조회 2,483
08-03-26 조회 3,394
08-03-26 조회 4,341
08-03-25 조회 3,816
08-03-25 조회 2,827
08-03-25 조회 4,143
08-03-25 조회 3,652
08-03-25 조회 4,070
08-03-25 조회 4,101
08-03-25 조회 3,762
08-03-25 조회 3,664
08-03-25 조회 2,916
08-03-25 조회 3,673
08-03-25 조회 5,370
08-03-21 조회 3,028
08-03-19 조회 5,192
08-03-18 조회 3,054
08-03-16 조회 3,017
08-03-14 조회 3,333
08-03-13 조회 3,724
08-03-13 조회 2,708
08-03-11 조회 3,032
08-03-11 조회 3,579
08-03-11 조회 3,074
08-03-11 조회 3,036
08-03-11 조회 2,832
08-03-11 조회 2,672
08-03-11 조회 2,612
08-03-11 조회 2,423
08-03-11 조회 2,433
08-03-11 조회 2,489
08-03-11 조회 2,463
08-03-11 조회 2,871
08-03-11 조회 2,948
08-03-08 조회 3,168
08-03-07 조회 4,284
08-03-07 조회 3,398
08-03-07 조회 3,058
08-03-06 조회 3,396
08-03-06 조회 3,143
08-03-06 조회 4,832
08-03-05 조회 2,767
08-03-04 조회 2,911
08-03-04 조회 2,608
08-03-04 조회 3,472
08-03-03 조회 4,441
08-02-28 조회 3,543
08-02-27 조회 3,031
08-02-22 조회 4,346
08-02-22 조회 5,722
08-02-22 조회 2,989
08-02-21 조회 4,658
08-02-21 조회 2,892
08-02-21 조회 4,888
08-02-21 조회 7,162
08-02-21 조회 2,680
08-02-21 조회 3,444
08-02-20 조회 3,114
08-02-19 조회 2,785
08-02-19 조회 3,649
08-02-19 조회 3,846
08-02-15 조회 2,816
08-02-15 조회 3,998
08-02-14 조회 4,508
08-02-14 조회 2,700
08-02-12 조회 3,155
08-02-11 조회 5,156
08-02-09 조회 5,893
08-02-09 조회 3,085
08-02-08 조회 2,939
08-02-05 조회 3,953
08-02-04 조회 3,151
08-02-03 조회 5,450
08-02-03 조회 2,860