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건
+
제목 글쓴이 날짜 조회
07-07-30 조회 5,148
07-07-30 조회 5,611
07-07-30 조회 5,532
07-07-29 조회 3,942
07-07-29 조회 3,680
07-07-29 조회 4,629
07-07-29 조회 4,490
07-07-28 조회 4,690
07-07-26 조회 4,600
07-07-25 조회 6,251
07-07-24 조회 6,511
07-07-21 조회 4,619
07-07-21 조회 3,974
07-07-21 조회 4,191
07-07-21 조회 3,507
07-07-21 조회 3,334
07-07-21 조회 3,285
07-07-20 조회 4,380
07-07-20 조회 3,527
07-07-20 조회 3,598
07-07-20 조회 3,279
07-07-20 조회 3,733
07-07-20 조회 4,462
07-07-18 조회 5,441
07-07-18 조회 4,640
07-07-16 조회 3,236
07-07-16 조회 3,164
07-07-13 조회 4,143
07-07-12 조회 2,861
07-07-09 조회 3,254
07-07-07 조회 3,490
07-07-07 조회 3,391
07-07-07 조회 3,517
07-07-06 조회 5,334
07-07-06 조회 3,060
07-07-06 조회 5,754
07-07-06 조회 4,313
07-07-06 조회 3,498
07-07-06 조회 4,542
07-07-06 조회 4,155
07-07-05 조회 4,138
07-07-05 조회 6,895
07-07-04 조회 3,510
07-07-02 조회 4,664
07-06-30 조회 4,548
07-06-29 조회 4,955
07-06-29 조회 4,477
07-06-28 조회 3,670
07-06-23 조회 3,319
07-06-21 조회 3,780
07-06-20 조회 7,449
07-06-20 조회 4,056
07-06-20 조회 5,798
07-06-19 조회 3,257
07-06-19 조회 1.1만
07-06-17 조회 3,727
07-06-16 조회 2,832
07-06-15 조회 4,229
07-06-12 조회 4,198
07-06-11 조회 4,068
07-06-11 조회 3,357
07-06-05 조회 3,695
07-06-05 조회 4,255
07-06-05 조회 4,257
07-06-05 조회 5,369
07-06-04 조회 7,439
07-05-31 조회 3,332
07-05-30 조회 3,408
07-05-29 조회 3,104
07-05-29 조회 2,833
07-05-29 조회 3,841
07-05-29 조회 2,930
07-05-29 조회 2,739
07-05-29 조회 5,973
07-05-29 조회 2,993
07-05-29 조회 3,020
07-05-29 조회 3,035
07-05-29 조회 3,144
07-05-29 조회 4,829
07-05-29 조회 2,829
07-05-29 조회 2,699
07-05-29 조회 2,525
07-05-29 조회 3,066
07-05-29 조회 3,095
07-05-28 조회 5,029
07-05-26 조회 3,317
07-05-20 조회 4,344
07-05-18 조회 6,100
07-05-18 조회 4,146
07-05-17 조회 9,264
07-05-17 조회 5,297
07-05-17 조회 3,971
07-05-16 조회 2,714
07-05-16 조회 3,854
07-05-15 조회 6,283
07-05-14 조회 6,469
07-05-13 조회 3,300
07-05-11 조회 5,613
07-05-10 조회 5,353
07-05-10 조회 5,425