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건
+
제목 글쓴이 날짜 조회
11-10-25 조회 2,493
11-10-18 조회 4,024
11-10-18 조회 2,400
11-10-15 조회 3,619
11-10-10 조회 2,673
11-10-02 조회 2,591
11-09-28 조회 2,406
11-09-24 조회 2,491
11-09-22 조회 2,389
11-09-05 조회 2,876
11-08-31 조회 2,253
11-08-31 조회 2,560
11-08-31 조회 2,418
11-08-29 조회 2,965
11-08-28 조회 2,461
11-08-25 조회 2,511
11-08-17 조회 2,229
11-08-16 조회 2,464
11-08-11 조회 2,917
11-08-07 조회 2,630
11-08-03 조회 2,341
11-07-22 조회 2,084
11-07-12 조회 3,303
11-06-27 조회 2,087
11-06-01 조회 1,751
11-05-17 조회 2,538
11-05-01 조회 2,609
11-04-28 조회 2,896
11-04-28 조회 2,946
11-04-13 조회 2,605
11-03-27 조회 2,728
11-03-27 조회 2,604
11-03-14 조회 2,017
11-03-02 조회 2,340
11-03-02 조회 2,573
11-02-27 조회 3,000
11-02-23 조회 2,379
11-02-19 조회 2,521
11-02-14 조회 4,135
11-02-03 조회 2,929
11-01-24 조회 3,872
11-01-04 조회 2,402
10-12-08 조회 5,413
10-11-15 조회 2,422
10-11-14 조회 2,596
10-11-14 조회 3,614
10-10-29 조회 3,689
10-10-19 조회 2,701
10-10-07 조회 2,527
10-10-05 조회 4,446
10-09-18 조회 2,744
10-09-18 조회 2,482
10-09-17 조회 4,887
10-09-15 조회 2,828
10-09-15 조회 2,353
10-09-15 조회 2,846
10-09-15 조회 2,675
10-09-11 조회 3,999
10-09-11 조회 2,508
10-09-11 조회 2,545
10-09-07 조회 3,821
10-09-07 조회 3,355
10-08-29 조회 2,815
10-07-01 조회 3,066
10-06-30 조회 2,470
10-06-30 조회 2,651
10-06-30 조회 3,005
10-06-13 조회 2,041
10-04-15 조회 3,212
10-04-04 조회 3,444
10-02-23 조회 3,545
10-02-09 조회 3,141
10-01-25 조회 2,651
10-01-25 조회 2,747
09-12-27 조회 4,396
09-11-23 조회 3,618
09-11-20 조회 4,852
09-08-30 조회 3,049
09-08-30 조회 3,048
09-08-12 조회 3,015
09-07-22 조회 4,077
09-07-22 조회 4,723
09-07-15 조회 5,891
09-07-11 조회 2,968
09-06-17 조회 2,711
09-06-15 조회 2,997
09-05-29 조회 3,275
09-05-11 조회 5,913
09-05-08 조회 2,670
09-04-30 조회 3,785
09-04-17 조회 3,102
09-04-04 조회 3,286
09-03-05 조회 3,671
09-02-09 조회 3,638
09-02-03 조회 6,144
08-12-27 조회 3,208
08-12-20 조회 4,297
08-11-21 조회 5,258
08-11-14 조회 2,825
08-11-03 조회 3,290