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,041
16년 전 조회 2,000
16년 전 조회 1,969
16년 전 조회 1,502
16년 전 조회 2,029
16년 전 조회 2,264
16년 전 조회 1,383
16년 전 조회 1,722
16년 전 조회 1,911
16년 전 조회 997
16년 전 조회 1,682
16년 전 조회 1,399
16년 전 조회 1,900
16년 전 조회 1,313
16년 전 조회 2,198
16년 전 조회 1,882
16년 전 조회 5,862
16년 전 조회 1,907
16년 전 조회 3,676
16년 전 조회 1,459
16년 전 조회 1,748
16년 전 조회 2,062
16년 전 조회 2,601
16년 전 조회 2,301
16년 전 조회 2,744
16년 전 조회 2,981
16년 전 조회 3,007
16년 전 조회 1,813
16년 전 조회 1,531
16년 전 조회 1,404
16년 전 조회 1,716
16년 전 조회 1,200
16년 전 조회 1,956
16년 전 조회 1,727
16년 전 조회 1,603
16년 전 조회 1,288
16년 전 조회 2,164
16년 전 조회 3,224
16년 전 조회 2,158
16년 전 조회 1,734
16년 전 조회 1,500
16년 전 조회 2,034
16년 전 조회 4,722
16년 전 조회 1,406
16년 전 조회 2,140
16년 전 조회 2,123
17년 전 조회 2,391
17년 전 조회 2,139
17년 전 조회 4,426
17년 전 조회 2,922
17년 전 조회 2,858
17년 전 조회 1,593
17년 전 조회 1,231
17년 전 조회 3,935
17년 전 조회 1,609
17년 전 조회 1,600
17년 전 조회 2,100
17년 전 조회 1,872
17년 전 조회 1,488
17년 전 조회 3,911
17년 전 조회 1,747
17년 전 조회 3,119
17년 전 조회 3,001
17년 전 조회 1,032
17년 전 조회 1,842
17년 전 조회 1,583
17년 전 조회 1,844
17년 전 조회 2,634
17년 전 조회 3,018
17년 전 조회 3,211
17년 전 조회 3,317
17년 전 조회 1,454
17년 전 조회 1,410
17년 전 조회 2,244
17년 전 조회 1,967
17년 전 조회 2,283
17년 전 조회 2,805
17년 전 조회 3,259
17년 전 조회 2,356
17년 전 조회 1,627
17년 전 조회 3,198
17년 전 조회 3,065
17년 전 조회 3,040
17년 전 조회 3,907
17년 전 조회 2,580
17년 전 조회 2,401
17년 전 조회 2,651
17년 전 조회 2,888
17년 전 조회 2,606
17년 전 조회 1,447
17년 전 조회 1,891
17년 전 조회 1,484
17년 전 조회 1,908
17년 전 조회 2,503
17년 전 조회 8,689
17년 전 조회 3,149
17년 전 조회 4,237
17년 전 조회 1,979
17년 전 조회 3,654
17년 전 조회 1,547
🐛 버그신고