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,188건
+
제목 글쓴이 날짜 조회
08-10-30 조회 2,701
08-10-30 조회 2,796
08-10-20 조회 2,530
08-10-11 조회 2,431
08-09-20 조회 4,177
08-09-20 조회 2,845
08-09-18 조회 2,722
08-09-18 조회 3,423
08-09-17 조회 3,290
08-09-05 조회 4,632
08-09-03 조회 2,757
08-08-18 조회 2,894
08-08-17 조회 2,631
08-08-13 조회 3,412
08-07-30 조회 3,473
08-07-28 조회 4,352
08-07-22 조회 5,583
08-07-22 조회 4,064
08-07-10 조회 3,037
08-07-08 조회 3,099
08-06-30 조회 3,859
08-06-30 조회 3,344
08-06-30 조회 3,658
08-06-14 조회 2,728
08-06-11 조회 7,090
08-06-05 조회 3,308
08-05-20 조회 4,821
08-05-13 조회 4,161
08-05-08 조회 3,115
08-05-08 조회 5,267
08-04-25 조회 4,065
08-04-22 조회 4,531
08-04-21 조회 3,171
08-04-17 조회 2,557
08-04-17 조회 2,955
08-04-17 조회 2,254
08-04-17 조회 5,224
08-04-17 조회 4,541
08-04-17 조회 4,533
08-04-17 조회 3,316
08-04-17 조회 3,147
08-04-17 조회 3,632
08-04-17 조회 4,993
08-04-17 조회 5,142
08-04-17 조회 3,349
08-04-04 조회 4,609
08-04-04 조회 2,835
08-04-04 조회 2,579
08-04-04 조회 2,809
08-04-04 조회 2,543
08-04-04 조회 2,783
08-04-03 조회 2,669
08-04-03 조회 2,738
08-04-02 조회 3,052
08-04-02 조회 3,203
08-03-31 조회 3,098
08-03-26 조회 4,276
08-03-11 조회 2,961
08-03-11 조회 2,373
08-03-11 조회 2,381
08-03-07 조회 4,214
08-03-07 조회 3,310
08-03-06 조회 4,758
08-03-04 조회 3,390
08-02-19 조회 3,786
08-02-03 조회 3,408
08-01-18 조회 3,994
08-01-15 조회 3,446
08-01-12 조회 4,294
08-01-12 조회 3,858
08-01-12 조회 3,810
07-12-24 조회 3,107
07-11-30 조회 3,942
07-11-08 조회 5,007
07-11-06 조회 3,859
07-10-26 조회 5,003
07-10-24 조회 4,188
07-10-22 조회 3,577
07-10-19 조회 4,755
07-10-09 조회 4,892
07-10-09 조회 6,757
07-10-05 조회 3,093
07-10-05 조회 4,026
07-10-03 조회 7,537
07-10-03 조회 3,584
07-10-03 조회 2,933
07-10-03 조회 2,855
07-09-28 조회 4,705
07-09-27 조회 3,769
07-09-27 조회 3,221
07-09-13 조회 3,367
07-08-28 조회 3,455
07-08-04 조회 4,840
07-08-01 조회 5,534
07-08-01 조회 4,941
07-07-30 조회 5,457
07-07-29 조회 3,603
07-07-21 조회 3,426
07-07-18 조회 5,382
07-07-16 조회 3,181