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,067
16년 전 조회 2,027
16년 전 조회 1,994
16년 전 조회 1,529
16년 전 조회 2,054
16년 전 조회 2,291
16년 전 조회 1,405
16년 전 조회 1,752
16년 전 조회 1,935
16년 전 조회 1,028
16년 전 조회 1,711
16년 전 조회 1,423
16년 전 조회 1,920
16년 전 조회 1,338
16년 전 조회 2,220
16년 전 조회 1,908
16년 전 조회 5,884
16년 전 조회 1,933
16년 전 조회 3,700
16년 전 조회 1,483
16년 전 조회 1,772
16년 전 조회 2,084
16년 전 조회 2,625
16년 전 조회 2,324
16년 전 조회 2,766
16년 전 조회 3,008
16년 전 조회 3,029
16년 전 조회 1,839
16년 전 조회 1,557
16년 전 조회 1,430
16년 전 조회 1,741
16년 전 조회 1,219
16년 전 조회 1,981
16년 전 조회 1,751
16년 전 조회 1,624
17년 전 조회 1,312
17년 전 조회 2,189
17년 전 조회 3,248
17년 전 조회 2,179
17년 전 조회 1,756
17년 전 조회 1,527
17년 전 조회 2,060
17년 전 조회 4,748
17년 전 조회 1,432
17년 전 조회 2,166
17년 전 조회 2,148
17년 전 조회 2,420
17년 전 조회 2,167
17년 전 조회 4,453
17년 전 조회 2,948
17년 전 조회 2,887
17년 전 조회 1,617
17년 전 조회 1,259
17년 전 조회 3,962
17년 전 조회 1,634
17년 전 조회 1,629
17년 전 조회 2,131
17년 전 조회 1,902
17년 전 조회 1,519
17년 전 조회 3,934
17년 전 조회 1,772
17년 전 조회 3,153
17년 전 조회 3,021
17년 전 조회 1,052
17년 전 조회 1,866
17년 전 조회 1,612
17년 전 조회 1,864
17년 전 조회 2,656
17년 전 조회 3,039
17년 전 조회 3,235
17년 전 조회 3,345
17년 전 조회 1,478
17년 전 조회 1,435
17년 전 조회 2,274
17년 전 조회 1,999
17년 전 조회 2,307
17년 전 조회 2,833
17년 전 조회 3,281
17년 전 조회 2,376
17년 전 조회 1,650
17년 전 조회 3,221
17년 전 조회 3,083
17년 전 조회 3,062
17년 전 조회 3,929
17년 전 조회 2,604
17년 전 조회 2,427
17년 전 조회 2,677
17년 전 조회 2,912
17년 전 조회 2,631
17년 전 조회 1,470
17년 전 조회 1,915
17년 전 조회 1,507
17년 전 조회 1,933
17년 전 조회 2,527
17년 전 조회 8,712
17년 전 조회 3,169
17년 전 조회 4,264
17년 전 조회 2,002
17년 전 조회 3,676
17년 전 조회 1,574