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 });
});
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
16년 전 조회 1,505
16년 전 조회 2,458
16년 전 조회 2,406
16년 전 조회 1,973
16년 전 조회 2,518
16년 전 조회 2,721
16년 전 조회 1,823
16년 전 조회 2,196
16년 전 조회 2,374
16년 전 조회 1,460
16년 전 조회 2,160
16년 전 조회 1,846
16년 전 조회 2,347
16년 전 조회 1,744
16년 전 조회 2,645
16년 전 조회 2,336
16년 전 조회 6,326
17년 전 조회 2,348
17년 전 조회 4,114
17년 전 조회 1,884
17년 전 조회 2,183
17년 전 조회 2,525
17년 전 조회 3,046
17년 전 조회 2,738
17년 전 조회 3,181
17년 전 조회 3,427
17년 전 조회 3,442
17년 전 조회 2,253
17년 전 조회 1,974
17년 전 조회 1,845
17년 전 조회 2,165
17년 전 조회 1,642
17년 전 조회 2,402
17년 전 조회 2,182
17년 전 조회 2,026
17년 전 조회 1,727
17년 전 조회 2,595
17년 전 조회 3,670
17년 전 조회 2,554
17년 전 조회 2,172
17년 전 조회 1,935
17년 전 조회 2,478
17년 전 조회 5,160
17년 전 조회 1,860
17년 전 조회 2,603
17년 전 조회 2,572
17년 전 조회 2,851
17년 전 조회 2,565
17년 전 조회 4,896
17년 전 조회 3,393
17년 전 조회 3,304
17년 전 조회 2,020
17년 전 조회 1,682
17년 전 조회 4,413
17년 전 조회 2,079
17년 전 조회 2,081
17년 전 조회 2,572
17년 전 조회 2,317
17년 전 조회 1,952
17년 전 조회 4,367
17년 전 조회 2,184
17년 전 조회 3,543
17년 전 조회 3,456
17년 전 조회 1,459
17년 전 조회 2,236
17년 전 조회 2,018
17년 전 조회 2,269
17년 전 조회 3,077
17년 전 조회 3,428
17년 전 조회 3,637
17년 전 조회 3,757
17년 전 조회 1,854
17년 전 조회 1,851
17년 전 조회 2,657
17년 전 조회 2,401
17년 전 조회 2,685
17년 전 조회 3,236
17년 전 조회 3,692
17년 전 조회 2,780
17년 전 조회 2,057
17년 전 조회 3,631
17년 전 조회 3,493
17년 전 조회 3,452
17년 전 조회 4,328
17년 전 조회 2,987
17년 전 조회 2,828
17년 전 조회 3,087
17년 전 조회 3,304
17년 전 조회 3,031
17년 전 조회 1,897
17년 전 조회 2,291
17년 전 조회 1,931
17년 전 조회 2,339
17년 전 조회 2,955
17년 전 조회 9,113
17년 전 조회 3,569
17년 전 조회 4,620
17년 전 조회 2,386
17년 전 조회 4,048
17년 전 조회 1,945