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

프로그램

8,187건
+
제목 글쓴이 날짜 조회
10-09-17 조회 2,350
10-09-16 조회 3,436
10-09-16 조회 2,159
10-09-16 조회 3,293
10-09-16 조회 2,235
10-09-16 조회 3,920
10-09-16 조회 2,175
10-09-16 조회 2,661
10-09-16 조회 2,177
10-09-15 조회 4,510
10-09-15 조회 2,866
10-09-15 조회 2,856
10-09-15 조회 2,860
10-09-15 조회 2,893
10-09-15 조회 2,641
10-09-15 조회 3,350
10-09-15 조회 2,850
10-09-15 조회 2,425
10-09-15 조회 4,283
10-09-15 조회 2,700
10-09-15 조회 2,915
10-09-15 조회 2,616
10-09-15 조회 3,520
10-09-15 조회 3,531
10-09-15 조회 3,190
10-09-15 조회 2,543
10-09-15 조회 2,745
10-09-15 조회 2,409
10-09-15 조회 2,420
10-09-15 조회 2,612
10-09-14 조회 4,134
10-09-11 조회 4,072
10-09-11 조회 3,002
10-09-11 조회 2,516
10-09-11 조회 2,708
10-09-11 조회 2,694
10-09-11 조회 2,572
10-09-11 조회 2,487
10-09-11 조회 2,387
10-09-11 조회 2,736
10-09-11 조회 2,834
10-09-11 조회 2,463
10-09-11 조회 2,461
10-09-11 조회 2,643
10-09-11 조회 3,112
10-09-11 조회 2,622
10-09-08 조회 3,004
10-09-08 조회 2,735
10-09-07 조회 3,512
10-09-07 조회 4,573
10-09-07 조회 3,898
10-09-07 조회 2,450
10-09-07 조회 3,432
10-09-07 조회 3,723
10-09-04 조회 2,989
10-08-29 조회 2,877
10-08-27 조회 4,179
10-08-27 조회 4,185
10-08-20 조회 7,059
10-08-06 조회 2,974
10-07-30 조회 5,736
10-07-27 조회 2,840
10-07-15 조회 3,179
10-07-06 조회 3,253
10-07-01 조회 3,132
10-07-01 조회 2,656
10-07-01 조회 2,889
10-07-01 조회 3,146
10-06-30 조회 3,035
10-06-30 조회 3,907
10-06-30 조회 2,900
10-06-30 조회 3,008
10-06-30 조회 2,468
10-06-30 조회 2,593
10-06-30 조회 2,611
10-06-30 조회 2,539
10-06-30 조회 2,538
10-06-30 조회 2,564
10-06-30 조회 2,706
10-06-30 조회 2,724
10-06-30 조회 4,134
10-06-30 조회 2,478
10-06-30 조회 3,158
10-06-30 조회 3,063
10-06-17 조회 3,167
10-06-16 조회 2,863
10-06-14 조회 3,431
10-06-13 조회 2,123
10-06-11 조회 2,776
10-06-11 조회 2,678
10-06-11 조회 4,388
10-06-11 조회 4,773
10-06-11 조회 3,459
10-06-01 조회 2,955
10-05-31 조회 3,659
10-05-31 조회 3,076
10-05-31 조회 2,639
10-05-22 조회 5,312
10-05-18 조회 2,996
10-05-18 조회 3,025