R

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

· 2009-01-20 (화) 13:50:37 · 4225 · 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건
+
제목 글쓴이 날짜 조회
12-08-29 조회 3,899
12-08-07 조회 3,567
12-08-03 조회 3,496
12-07-31 조회 3,611
12-07-30 조회 3,572
12-07-16 조회 3,776
12-07-15 조회 3,470
12-07-07 조회 3,472
12-07-06 조회 3,568
12-07-03 조회 3,628
12-06-29 조회 3,213
12-06-22 조회 3,581
12-06-17 조회 3,689
12-05-21 조회 3,766
12-05-02 조회 3,353
12-05-02 조회 4,143
12-05-02 조회 3,258
12-04-30 조회 3,399
12-04-30 조회 3,111
12-03-17 조회 3,924
12-03-10 조회 3,333
12-03-08 조회 3,747
12-03-03 조회 3,510
12-02-27 조회 4,920
12-02-17 조회 4,271
12-02-16 조회 4,415
12-02-03 조회 3,258
12-01-31 조회 3,000
12-01-24 조회 3,073
12-01-17 조회 3,825
12-01-05 조회 3,383
11-12-30 조회 2,997
11-12-23 조회 4,598
11-12-08 조회 3,356
11-12-07 조회 4,337
11-11-27 조회 3,765
11-11-25 조회 4,084
11-11-23 조회 3,476
11-11-22 조회 3,415
11-11-09 조회 3,172
11-10-23 조회 3,071
11-10-19 조회 3,049
11-10-08 조회 2,756
11-10-04 조회 2,773
11-10-04 조회 5,213
11-09-01 조회 4,273
11-08-13 조회 2,447
11-08-06 조회 3,137
11-07-11 조회 3,533
11-06-27 조회 2,902
11-06-21 조회 2,528
11-06-13 조회 2,352
11-06-07 조회 2,352
11-05-26 조회 2,349
11-04-20 조회 2,675
11-03-21 조회 2,766
11-03-18 조회 2,459
11-03-11 조회 2,496
11-02-07 조회 2,313
11-01-18 조회 2,638
11-01-12 조회 2,360
11-01-06 조회 2,478
10-12-10 조회 2,738
10-12-09 조회 2,394
10-12-08 조회 4,989
10-11-29 조회 2,490
10-11-28 조회 2,724
10-11-28 조회 2,568
10-11-19 조회 2,756
10-11-04 조회 2,675
10-10-21 조회 2,382
10-10-19 조회 3,334
10-10-12 조회 2,658
10-10-07 조회 2,461
10-09-30 조회 3,443
10-09-17 조회 3,840
10-09-17 조회 3,801
10-05-31 조회 3,469
09-12-31 조회 3,607
09-07-23 조회 4,911
08-09-16 조회 3,168
08-09-06 조회 2,887
08-09-04 조회 3,320
08-08-16 조회 4,372
08-08-15 조회 3,248
08-08-14 조회 4,457
08-08-12 조회 3,815
08-07-23 조회 2,743
08-07-10 조회 3,679
08-07-04 조회 2,910
08-06-27 조회 7,564
08-06-19 조회 4,852
08-05-27 조회 5,466
08-05-25 조회 5,293
08-05-23 조회 3,362
08-05-23 조회 4,500
08-05-21 조회 4,882
08-05-20 조회 4,010
08-05-20 조회 3,247
08-04-18 조회 4,277