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-10-04 조회 2,825
10-10-03 조회 2,031
10-10-03 조회 2,544
10-10-02 조회 2,429
10-10-02 조회 2,023
10-10-02 조회 2,050
10-10-02 조회 1,949
10-10-02 조회 1,912
10-10-01 조회 2,133
10-10-01 조회 2,511
10-10-01 조회 3,623
10-10-01 조회 2,163
10-10-01 조회 2,284
10-10-01 조회 2,350
10-09-30 조회 2,308
10-09-30 조회 2,451
10-09-30 조회 2,024
10-09-30 조회 3,584
10-09-30 조회 2,131
10-09-30 조회 3,105
10-09-30 조회 2,099
10-09-30 조회 2,071
10-09-30 조회 2,967
10-09-30 조회 2,415
10-09-30 조회 2,672
10-09-30 조회 2,995
10-09-30 조회 2,651
10-09-30 조회 2,747
10-09-30 조회 2,170
10-09-29 조회 3,623
10-09-29 조회 2,370
10-09-29 조회 2,121
10-09-29 조회 2,521
10-09-29 조회 2,194
10-09-29 조회 3,481
10-09-30 조회 2,412
10-09-29 조회 2,186
10-09-29 조회 2,358
10-09-29 조회 2,322
10-09-29 조회 2,340
10-09-29 조회 2,380
10-09-29 조회 1,880
10-09-29 조회 1,835
10-09-29 조회 1,786
10-09-29 조회 2,458
10-09-29 조회 2,279
10-09-28 조회 2,070
10-09-28 조회 2,093
10-09-28 조회 2,463
10-09-28 조회 4,723
10-09-28 조회 2,611
10-09-28 조회 3,297
10-09-27 조회 2,482
10-09-27 조회 2,369
10-09-27 조회 4,040
10-09-26 조회 3,037
10-09-26 조회 3,918
10-09-26 조회 4,223
10-09-25 조회 2,841
10-09-25 조회 2,470
10-09-25 조회 2,858
10-09-25 조회 2,308
10-09-25 조회 2,601
10-09-25 조회 2,495
10-09-25 조회 2,861
10-09-24 조회 3,199
10-09-24 조회 2,295
10-09-24 조회 2,942
10-09-24 조회 2,648
10-09-24 조회 2,410
10-09-24 조회 2,474
10-09-23 조회 2,757
10-09-22 조회 2,135
10-09-21 조회 2,347
10-09-21 조회 3,987
10-09-21 조회 3,016
10-09-21 조회 2,184
10-09-21 조회 2,207
10-09-20 조회 2,706
10-09-20 조회 2,796
10-09-20 조회 3,160
10-09-19 조회 2,474
10-09-19 조회 2,862
10-09-19 조회 2,153
10-09-18 조회 2,545
10-09-18 조회 2,816
10-09-18 조회 4,195
10-09-18 조회 2,603
10-09-18 조회 2,574
10-09-18 조회 2,380
10-09-18 조회 2,306
10-09-17 조회 2,286
10-09-17 조회 4,976
10-09-17 조회 4,399
10-09-17 조회 3,630
10-09-17 조회 4,000
10-09-17 조회 3,118
10-09-17 조회 2,516
10-09-17 조회 2,642
10-09-17 조회 3,950