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건
+
제목 글쓴이 날짜 조회
09-10-03 조회 3,190
08-02-03 조회 3,493
08-02-03 조회 3,431
08-01-30 조회 4,946
08-01-29 조회 2,814
08-01-27 조회 3,951
08-01-27 조회 2,889
08-01-27 조회 3,169
08-01-26 조회 8,715
08-01-26 조회 3,267
08-01-24 조회 5,322
08-01-23 조회 3,662
08-01-21 조회 3,699
08-01-21 조회 3,449
08-01-21 조회 3,472
08-01-18 조회 3,984
08-01-18 조회 4,620
08-01-18 조회 6,781
08-01-18 조회 4,058
08-01-17 조회 4,046
08-01-17 조회 3,876
08-01-16 조회 3,129
08-01-15 조회 3,507
08-01-14 조회 6,758
08-01-12 조회 4,360
08-01-12 조회 3,921
08-01-12 조회 4,637
08-01-12 조회 3,879
08-01-12 조회 4,173
08-01-11 조회 7,206
08-01-10 조회 3,949
08-01-08 조회 3,481
08-01-08 조회 3,964
08-01-06 조회 2,746
08-01-04 조회 1.1만
08-01-02 조회 5,828
07-12-28 조회 4,763
07-12-24 조회 3,178
07-12-21 조회 4,880
07-12-17 조회 3,662
07-12-14 조회 5,033
07-12-13 조회 6,469
07-12-10 조회 5,109
07-12-10 조회 3,985
07-12-10 조회 4,385
07-12-08 조회 3,741
07-12-07 조회 4,073
07-12-07 조회 3,204
07-12-06 조회 4,953
07-12-04 조회 3,536
07-12-04 조회 3,683
07-12-03 조회 3,440
07-12-03 조회 4,463
07-12-02 조회 3,292
07-11-30 조회 4,041
07-11-30 조회 5,271
07-11-30 조회 5,872
07-11-29 조회 3,721
07-11-27 조회 4,172
07-11-27 조회 5,950
07-11-27 조회 4,049
07-11-26 조회 3,173
07-11-23 조회 4,628
07-11-23 조회 4,360
07-11-22 조회 5,268
07-11-21 조회 3,485
07-11-21 조회 3,607
07-11-21 조회 1.2만
07-11-20 조회 4,991
07-11-16 조회 4,844
07-11-13 조회 4,511
07-11-12 조회 4,239
07-11-10 조회 5,617
07-11-08 조회 6,778
07-11-08 조회 5,106
07-11-07 조회 4,576
07-11-07 조회 5,025
07-11-06 조회 3,569
07-11-06 조회 3,928
07-11-05 조회 5,262
07-11-02 조회 4,150
07-11-01 조회 5,616
07-10-31 조회 3,301
07-10-30 조회 3,769
07-10-29 조회 3,768
07-10-26 조회 5,086
07-10-25 조회 5,173
07-10-25 조회 3,951
07-10-24 조회 3,944
07-10-24 조회 4,261
07-10-24 조회 4,120
07-10-24 조회 3,395
07-10-24 조회 3,516
07-10-23 조회 6,164
07-10-23 조회 5,550
07-10-22 조회 4,277
07-10-22 조회 3,657
07-10-22 조회 4,200
07-10-22 조회 3,778
07-10-19 조회 4,830