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건
+
제목 글쓴이 날짜 조회
08-06-15 조회 3,234
08-06-15 조회 2,475
08-06-14 조회 2,804
08-06-14 조회 3,713
08-06-14 조회 3,400
08-06-12 조회 2,275
08-06-11 조회 2,316
08-06-11 조회 2,409
08-06-11 조회 7,439
08-06-11 조회 7,171
08-06-08 조회 3,350
08-06-07 조회 2,283
08-06-05 조회 2,405
08-06-05 조회 3,367
08-06-05 조회 2,742
08-06-05 조회 2,391
08-06-05 조회 2,412
08-06-04 조회 2,332
08-06-03 조회 2,326
08-06-03 조회 5,398
08-06-03 조회 3,633
08-06-02 조회 2,937
08-06-02 조회 4,074
08-06-01 조회 2,683
08-05-31 조회 2,388
08-05-31 조회 2,398
08-05-31 조회 2,497
08-05-30 조회 2,373
08-05-29 조회 2,512
08-05-29 조회 3,786
08-05-27 조회 5,612
08-05-26 조회 2,456
08-05-26 조회 5,371
08-05-25 조회 5,458
08-05-24 조회 2,516
08-05-23 조회 3,523
08-05-23 조회 2,939
08-05-23 조회 4,691
08-05-22 조회 2,700
08-05-21 조회 5,041
08-05-21 조회 4,838
08-05-21 조회 3,980
08-05-20 조회 4,574
08-05-20 조회 4,149
08-05-20 조회 3,373
08-05-20 조회 4,649
08-05-20 조회 3,995
08-05-20 조회 4,890
08-05-19 조회 2,434
08-05-16 조회 3,552
08-05-15 조회 2,616
08-05-15 조회 2,449
08-05-15 조회 2,437
08-05-14 조회 2,384
08-05-13 조회 2,838
08-05-13 조회 4,244
08-05-13 조회 4,654
08-05-09 조회 4,425
08-05-08 조회 3,177
08-05-08 조회 5,333
08-05-08 조회 2,691
08-05-07 조회 2,389
08-05-07 조회 2,533
08-05-07 조회 2,334
08-05-01 조회 2,649
08-05-01 조회 2,997
08-04-29 조회 3,844
08-04-28 조회 3,667
08-04-26 조회 2,695
08-04-26 조회 2,442
08-04-26 조회 3,725
08-04-25 조회 4,145
08-04-23 조회 4,585
08-04-22 조회 4,546
08-04-22 조회 3,680
08-04-22 조회 5,261
08-04-22 조회 4,630
08-04-22 조회 7,016
08-04-22 조회 4,072
08-04-21 조회 3,223
08-04-21 조회 3,259
08-04-21 조회 3,198
08-04-21 조회 3,022
08-04-21 조회 4,128
08-04-20 조회 3,293
08-04-20 조회 2,973
08-04-20 조회 3,501
08-04-19 조회 2,402
08-04-18 조회 3,109
08-04-18 조회 4,444
08-04-17 조회 3,694
08-04-17 조회 3,151
08-04-17 조회 3,358
08-04-17 조회 2,647
08-04-17 조회 3,034
08-04-17 조회 2,518
08-04-17 조회 3,073
08-04-17 조회 3,131
08-04-17 조회 2,329
08-04-17 조회 4,626