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,552
16년 전 조회 2,491
16년 전 조회 2,447
16년 전 조회 2,023
16년 전 조회 2,559
16년 전 조회 2,754
16년 전 조회 1,861
16년 전 조회 2,244
16년 전 조회 2,419
16년 전 조회 1,496
16년 전 조회 2,204
16년 전 조회 1,884
16년 전 조회 2,388
16년 전 조회 1,785
16년 전 조회 2,685
16년 전 조회 2,379
16년 전 조회 6,360
17년 전 조회 2,384
17년 전 조회 4,145
17년 전 조회 1,910
17년 전 조회 2,207
17년 전 조회 2,557
17년 전 조회 3,079
17년 전 조회 2,773
17년 전 조회 3,205
17년 전 조회 3,450
17년 전 조회 3,478
17년 전 조회 2,282
17년 전 조회 1,995
17년 전 조회 1,874
17년 전 조회 2,200
17년 전 조회 1,671
17년 전 조회 2,427
17년 전 조회 2,208
17년 전 조회 2,051
17년 전 조회 1,743
17년 전 조회 2,624
17년 전 조회 3,701
17년 전 조회 2,583
17년 전 조회 2,200
17년 전 조회 1,964
17년 전 조회 2,498
17년 전 조회 5,190
17년 전 조회 1,893
17년 전 조회 2,632
17년 전 조회 2,593
17년 전 조회 2,874
17년 전 조회 2,589
17년 전 조회 4,924
17년 전 조회 3,418
17년 전 조회 3,326
17년 전 조회 2,046
17년 전 조회 1,709
17년 전 조회 4,438
17년 전 조회 2,100
17년 전 조회 2,104
17년 전 조회 2,596
17년 전 조회 2,342
17년 전 조회 1,974
17년 전 조회 4,385
17년 전 조회 2,207
17년 전 조회 3,568
17년 전 조회 3,487
17년 전 조회 1,480
17년 전 조회 2,259
17년 전 조회 2,040
17년 전 조회 2,293
17년 전 조회 3,097
17년 전 조회 3,457
17년 전 조회 3,663
17년 전 조회 3,780
17년 전 조회 1,874
17년 전 조회 1,875
17년 전 조회 2,682
17년 전 조회 2,428
17년 전 조회 2,711
17년 전 조회 3,259
17년 전 조회 3,722
17년 전 조회 2,802
17년 전 조회 2,078
17년 전 조회 3,644
17년 전 조회 3,511
17년 전 조회 3,472
17년 전 조회 4,352
17년 전 조회 3,001
17년 전 조회 2,846
17년 전 조회 3,112
17년 전 조회 3,326
17년 전 조회 3,054
17년 전 조회 1,915
17년 전 조회 2,309
17년 전 조회 1,963
17년 전 조회 2,363
17년 전 조회 2,979
17년 전 조회 9,137
17년 전 조회 3,587
17년 전 조회 4,643
17년 전 조회 2,411
17년 전 조회 4,067
17년 전 조회 1,969