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건
+
제목 글쓴이 날짜 조회
07-07-16 조회 3,127
07-07-06 조회 3,015
07-07-06 조회 3,443
07-06-23 조회 3,271
07-06-16 조회 2,780
07-05-20 조회 4,289
07-05-09 조회 3,465
07-05-09 조회 6,104
07-05-04 조회 2,698
07-04-30 조회 9,832
07-04-27 조회 4,338
07-04-26 조회 3,453
07-04-25 조회 5,297
07-04-18 조회 7,794
07-04-13 조회 3,131
07-04-12 조회 6,641
07-04-12 조회 5,054
07-04-12 조회 3,361
07-04-11 조회 5,725
07-04-05 조회 6,369
07-03-24 조회 4,425
07-03-20 조회 3,748
07-03-18 조회 3,992
07-03-18 조회 4,740
07-03-17 조회 4,241
07-03-16 조회 4,134
07-03-15 조회 5,297
07-03-13 조회 5,407
07-03-13 조회 3,589
07-03-08 조회 4,505
07-03-08 조회 3,988
07-03-08 조회 3,304
07-03-08 조회 4,189
07-03-05 조회 4,449
07-03-04 조회 2,917
07-03-01 조회 5,951
07-02-28 조회 3,234
07-02-27 조회 4,415
07-02-26 조회 3,336
07-02-26 조회 3,042
07-02-23 조회 3,674
07-02-23 조회 3,645
07-02-22 조회 4,026
07-02-22 조회 3,839
07-02-19 조회 3,857
07-02-17 조회 4,876
07-02-14 조회 8,181
07-02-12 조회 3,949
07-02-10 조회 3,573
07-02-02 조회 3,817
07-01-31 조회 3,491
07-01-29 조회 3,350
07-01-25 조회 5,126
07-01-21 조회 3,273
07-01-19 조회 3,057
06-12-15 조회 4,070
06-12-15 조회 4,474
06-12-15 조회 2,962
06-12-15 조회 4,513
06-12-15 조회 3,402
06-12-15 조회 4,102
06-12-15 조회 3,049
06-12-15 조회 2,779
06-12-15 조회 4,638
06-12-15 조회 3,184
06-12-15 조회 3,287
06-12-07 조회 4,737
06-12-07 조회 4,021
06-12-04 조회 4,670
06-11-27 조회 3,712
06-11-21 조회 4,023
06-11-15 조회 3,454
06-11-04 조회 3,346
06-10-29 조회 4,000
06-10-13 조회 3,869
06-10-13 조회 4,228
06-10-13 조회 4,182
06-10-12 조회 5,372
06-10-12 조회 4,289
06-10-04 조회 3,791
06-10-02 조회 4,568
06-09-29 조회 3,057
06-09-26 조회 3,396
06-09-26 조회 3,658
06-09-26 조회 3,304
06-09-26 조회 3,451
06-09-26 조회 4,359
06-09-25 조회 4,662
06-09-22 조회 5,000
06-09-22 조회 3,565
06-09-21 조회 4,340
06-09-21 조회 4,346
06-09-21 조회 3,551
06-09-21 조회 5,202
06-09-21 조회 3,729
06-09-21 조회 3,460
06-09-20 조회 3,040
06-09-15 조회 3,168
06-09-13 조회 3,484
06-09-11 조회 3,285