R

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

· 2009-01-20 (화) 13:50:37 · 4249 · 1
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,188건
+
제목 글쓴이 날짜 조회
10-05-31 조회 2,906
10-04-17 조회 4,697
10-03-23 조회 5,847
10-02-26 조회 3,364
10-02-23 조회 3,330
10-02-11 조회 3,947
10-02-09 조회 3,014
10-01-26 조회 3,468
10-01-23 조회 6,799
10-01-19 조회 3,503
10-01-13 조회 3,704
09-12-06 조회 4,640
09-11-24 조회 4,190
09-11-19 조회 3,064
09-11-11 조회 3,663
09-08-30 조회 3,145
09-08-12 조회 3,142
09-07-21 조회 3,323
09-07-19 조회 3,208
09-07-11 조회 3,126
09-06-15 조회 2,900
09-05-29 조회 3,074
09-05-28 조회 3,505
09-05-05 조회 3,363
09-04-07 조회 3,576
09-02-23 조회 4,373
09-02-17 조회 3,115
09-02-17 조회 2,494
09-02-09 조회 2,602
09-01-23 조회 3,408
09-01-17 조회 4,233
09-01-08 조회 3,186
08-11-07 조회 4,439
08-11-01 조회 4,927
08-10-30 조회 3,524
08-10-16 조회 3,440
08-10-02 조회 2,577
08-09-22 조회 3,932
08-09-22 조회 2,897
08-09-20 조회 5,395
08-09-20 조회 4,455
08-09-20 조회 3,527
08-09-20 조회 2,906
08-09-20 조회 3,102
08-09-20 조회 4,090
08-09-20 조회 3,574
08-09-20 조회 3,161
08-09-18 조회 3,407
08-09-06 조회 3,011
08-09-06 조회 2,755
08-09-05 조회 3,410
08-09-05 조회 5,619
08-09-03 조회 4,425
08-09-03 조회 2,681
08-07-31 조회 3,159
08-07-18 조회 3,761
08-06-19 조회 3,105
08-06-15 조회 3,098
08-06-14 조회 3,552
08-05-23 조회 2,789
08-05-13 조회 2,696
08-04-22 조회 4,376
08-04-22 조회 5,074
08-04-22 조회 6,814
08-04-17 조회 2,991
08-04-17 조회 3,575
08-04-17 조회 3,673
08-04-17 조회 5,914
08-04-17 조회 3,109
08-04-17 조회 3,442
08-04-06 조회 3,526
08-04-05 조회 3,105
08-04-04 조회 7,166
08-04-04 조회 4,454
08-04-04 조회 3,806
08-04-04 조회 3,985
08-04-04 조회 2,865
08-04-04 조회 2,651
08-04-04 조회 2,691
08-04-04 조회 2,888
08-04-04 조회 2,642
08-04-04 조회 2,614
08-04-04 조회 4,126
08-04-03 조회 2,648
08-04-03 조회 3,856
08-04-02 조회 3,077
08-04-02 조회 2,825
08-03-25 조회 3,681
08-03-11 조회 3,444
08-03-11 조회 2,952
08-03-11 조회 2,908
08-03-11 조회 2,707
08-03-11 조회 2,482
08-03-11 조회 2,287
08-03-11 조회 2,345
08-03-07 조회 2,886
08-03-05 조회 2,626
08-02-27 조회 2,855
08-02-21 조회 2,737
08-02-21 조회 3,310