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,276
16년 전 조회 2,234
16년 전 조회 2,199
16년 전 조회 1,744
16년 전 조회 2,312
16년 전 조회 2,518
16년 전 조회 1,620
16년 전 조회 1,976
16년 전 조회 2,145
16년 전 조회 1,233
16년 전 조회 1,947
16년 전 조회 1,627
16년 전 조회 2,123
16년 전 조회 1,546
16년 전 조회 2,448
16년 전 조회 2,116
16년 전 조회 6,141
16년 전 조회 2,133
16년 전 조회 3,916
16년 전 조회 1,675
16년 전 조회 1,970
16년 전 조회 2,312
16년 전 조회 2,840
16년 전 조회 2,536
16년 전 조회 2,972
17년 전 조회 3,220
17년 전 조회 3,236
17년 전 조회 2,032
17년 전 조회 1,757
17년 전 조회 1,618
17년 전 조회 1,956
17년 전 조회 1,431
17년 전 조회 2,189
17년 전 조회 1,963
17년 전 조회 1,817
17년 전 조회 1,523
17년 전 조회 2,393
17년 전 조회 3,457
17년 전 조회 2,358
17년 전 조회 1,961
17년 전 조회 1,736
17년 전 조회 2,261
17년 전 조회 4,949
17년 전 조회 1,668
17년 전 조회 2,405
17년 전 조회 2,364
17년 전 조회 2,642
17년 전 조회 2,355
17년 전 조회 4,677
17년 전 조회 3,177
17년 전 조회 3,091
17년 전 조회 1,801
17년 전 조회 1,456
17년 전 조회 4,188
17년 전 조회 1,859
17년 전 조회 1,864
17년 전 조회 2,337
17년 전 조회 2,106
17년 전 조회 1,738
17년 전 조회 4,159
17년 전 조회 1,981
17년 전 조회 3,326
17년 전 조회 3,254
17년 전 조회 1,243
17년 전 조회 2,058
17년 전 조회 1,820
17년 전 조회 2,063
17년 전 조회 2,884
17년 전 조회 3,244
17년 전 조회 3,453
17년 전 조회 3,557
17년 전 조회 1,661
17년 전 조회 1,649
17년 전 조회 2,453
17년 전 조회 2,208
17년 전 조회 2,495
17년 전 조회 3,039
17년 전 조회 3,516
17년 전 조회 2,596
17년 전 조회 1,871
17년 전 조회 3,452
17년 전 조회 3,300
17년 전 조회 3,266
17년 전 조회 4,138
17년 전 조회 2,786
17년 전 조회 2,647
17년 전 조회 2,893
17년 전 조회 3,131
17년 전 조회 2,845
17년 전 조회 1,685
17년 전 조회 2,092
17년 전 조회 1,698
17년 전 조회 2,148
17년 전 조회 2,767
17년 전 조회 8,934
17년 전 조회 3,377
17년 전 조회 4,442
17년 전 조회 2,207
17년 전 조회 3,881
17년 전 조회 1,779