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건
+
제목 글쓴이 날짜 조회
10-05-15 조회 4,313
10-05-10 조회 3,002
10-04-29 조회 5,716
10-04-28 조회 3,915
10-04-17 조회 4,848
10-04-15 조회 3,294
10-04-04 조회 3,532
10-04-02 조회 2,814
10-03-23 조회 5,997
10-03-19 조회 5,546
10-03-05 조회 5,295
10-03-01 조회 6,971
10-02-27 조회 5,137
10-02-26 조회 3,526
10-02-23 조회 3,479
10-02-23 조회 3,637
10-02-19 조회 3,332
10-02-17 조회 5,750
10-02-17 조회 4,479
10-02-17 조회 3,899
10-02-12 조회 3,216
10-02-12 조회 3,558
10-02-12 조회 3,885
10-02-11 조회 3,023
10-02-11 조회 4,102
10-02-09 조회 3,406
10-02-09 조회 3,503
10-02-09 조회 3,216
10-02-09 조회 3,875
10-02-09 조회 3,140
10-02-09 조회 3,485
10-01-26 조회 3,597
10-01-25 조회 2,731
10-01-25 조회 2,834
10-01-23 조회 3,433
10-01-23 조회 6,945
10-01-20 조회 3,167
10-01-19 조회 3,647
10-01-13 조회 3,845
10-01-07 조회 3,037
10-01-07 조회 2,828
10-01-07 조회 3,789
10-01-07 조회 6,498
09-12-31 조회 3,788
09-12-27 조회 4,473
09-12-18 조회 3,269
09-12-14 조회 5,293
09-12-14 조회 6,167
09-12-06 조회 4,887
09-11-26 조회 3,805
09-11-24 조회 3,947
09-11-24 조회 4,364
09-11-23 조회 3,705
09-11-21 조회 7,065
09-11-20 조회 4,932
09-11-19 조회 2,855
09-11-19 조회 3,212
09-11-13 조회 6,685
09-11-11 조회 3,806
09-11-09 조회 4,831
09-11-09 조회 4,105
09-11-09 조회 2,997
09-11-04 조회 6,829
09-10-26 조회 3,959
09-10-10 조회 7,447
09-10-09 조회 3,454
09-10-08 조회 5,420
09-09-19 조회 4,495
09-09-15 조회 3,629
09-09-14 조회 3,661
09-09-11 조회 5,857
09-09-04 조회 4,912
09-08-31 조회 4,258
09-08-31 조회 4,471
09-08-30 조회 3,538
09-08-30 조회 3,309
09-08-30 조회 3,135
09-08-30 조회 2,821
09-08-30 조회 3,122
09-08-30 조회 3,354
09-08-30 조회 3,057
09-08-16 조회 6,392
09-08-14 조회 5,373
09-08-12 조회 3,325
09-08-12 조회 3,110
09-08-12 조회 3,820
09-07-24 조회 6,070
09-07-23 조회 5,123
09-07-22 조회 4,211
09-07-22 조회 5,782
09-07-22 조회 4,804
09-07-22 조회 2,948
09-07-21 조회 2,840
09-07-21 조회 3,476
09-07-19 조회 3,362
09-07-17 조회 4,077
09-07-17 조회 3,597
09-07-17 조회 2,861
09-07-15 조회 5,954
09-07-11 조회 3,036