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-27 조회 2,974
10-10-27 조회 2,213
10-10-26 조회 3,317
10-10-26 조회 2,311
10-10-26 조회 2,205
10-10-26 조회 2,215
10-10-25 조회 2,137
10-10-24 조회 2,325
10-10-24 조회 2,364
10-10-24 조회 2,657
10-10-24 조회 4,822
10-10-24 조회 3,340
10-10-23 조회 2,281
10-10-23 조회 3,097
10-10-22 조회 2,127
10-10-22 조회 2,282
10-10-22 조회 3,458
10-10-22 조회 3,173
10-10-22 조회 2,199
10-10-21 조회 2,512
10-10-21 조회 2,463
10-10-21 조회 2,503
10-10-21 조회 2,651
10-10-21 조회 2,394
10-10-21 조회 2,393
10-10-21 조회 2,295
10-10-21 조회 2,472
10-10-21 조회 2,404
10-10-21 조회 3,034
10-10-21 조회 2,184
10-10-20 조회 2,159
10-10-20 조회 2,878
10-10-19 조회 2,891
10-10-19 조회 2,732
10-10-19 조회 2,281
10-10-19 조회 3,017
10-10-19 조회 2,426
10-10-19 조회 3,055
10-10-19 조회 3,472
10-10-19 조회 3,040
10-10-19 조회 9,097
10-10-19 조회 2,617
10-10-19 조회 2,767
10-10-19 조회 2,548
10-10-18 조회 2,650
10-10-18 조회 2,566
10-10-18 조회 2,631
10-10-18 조회 2,316
10-10-18 조회 3,457
10-10-17 조회 2,448
10-10-17 조회 2,310
10-10-17 조회 3,024
10-10-17 조회 2,798
10-10-16 조회 2,459
10-10-16 조회 2,362
10-10-16 조회 2,465
10-10-16 조회 2,836
10-10-16 조회 2,214
10-10-15 조회 2,327
10-10-14 조회 2,496
10-10-14 조회 3,305
10-10-13 조회 2,479
10-10-13 조회 2,624
10-10-13 조회 2,340
10-10-13 조회 2,362
10-10-12 조회 2,783
10-10-12 조회 3,095
10-10-12 조회 2,357
10-10-12 조회 2,832
10-10-11 조회 3,003
10-10-09 조회 2,438
10-10-09 조회 2,302
10-10-07 조회 2,627
10-10-07 조회 2,577
10-10-07 조회 2,277
10-10-07 조회 2,597
10-10-07 조회 2,713
10-10-07 조회 2,736
10-10-06 조회 4,681
10-10-06 조회 2,156
10-10-06 조회 2,917
10-10-06 조회 2,271
10-10-06 조회 3,102
10-10-06 조회 2,094
10-10-06 조회 2,348
10-10-05 조회 2,251
10-10-05 조회 2,300
10-10-05 조회 3,203
10-10-05 조회 4,525
10-10-05 조회 3,453
10-10-05 조회 3,417
10-10-05 조회 2,261
10-10-05 조회 2,475
10-10-05 조회 2,330
10-10-04 조회 2,116
10-10-04 조회 2,497
10-10-04 조회 2,208
10-10-04 조회 2,729
10-10-04 조회 1,991
10-10-04 조회 1,896