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-11-17 조회 2,337
10-11-16 조회 2,648
10-11-16 조회 2,150
10-11-16 조회 2,381
10-11-15 조회 2,856
10-11-15 조회 2,369
10-11-15 조회 3,117
10-11-15 조회 2,134
10-11-15 조회 2,246
10-11-15 조회 2,789
10-11-15 조회 2,491
10-11-14 조회 2,151
10-11-14 조회 4,358
10-11-14 조회 2,687
10-11-14 조회 3,700
10-11-13 조회 3,520
10-11-13 조회 2,502
10-11-13 조회 3,725
10-11-12 조회 2,328
10-11-12 조회 2,715
10-11-11 조회 3,892
10-11-11 조회 2,104
10-11-11 조회 2,722
10-11-10 조회 2,947
10-11-10 조회 2,218
10-11-10 조회 2,568
10-11-10 조회 2,050
10-11-09 조회 3,382
10-11-09 조회 2,897
10-11-09 조회 2,230
10-11-09 조회 1,931
10-11-09 조회 1,997
10-11-09 조회 2,541
10-11-09 조회 2,502
10-11-08 조회 1,910
10-11-08 조회 1,797
10-11-08 조회 2,086
10-11-08 조회 2,090
10-11-08 조회 3,012
10-11-08 조회 1,930
10-11-08 조회 2,074
10-11-08 조회 2,036
10-11-08 조회 2,290
10-11-08 조회 3,062
10-11-07 조회 2,951
10-11-07 조회 1.6만
10-11-07 조회 4,531
10-11-06 조회 2,085
10-11-06 조회 2,095
10-11-06 조회 2,247
10-11-06 조회 2,025
10-11-06 조회 1,989
10-11-06 조회 1.3만
10-11-05 조회 2,577
10-11-05 조회 2,552
10-11-05 조회 2,683
10-11-04 조회 2,591
10-11-04 조회 1,940
10-11-04 조회 2,795
10-11-04 조회 2,326
10-11-04 조회 1,967
10-11-04 조회 2,146
10-11-04 조회 2,204
10-11-04 조회 2,782
10-11-04 조회 2,131
10-11-04 조회 2,108
10-11-04 조회 2,337
10-11-03 조회 2,115
10-11-03 조회 2,972
10-11-03 조회 2,693
10-11-03 조회 4,272
10-11-03 조회 2,973
10-11-03 조회 2,002
10-11-03 조회 1,954
10-11-02 조회 2,176
10-11-02 조회 2,787
10-11-02 조회 2,810
10-11-01 조회 2,018
10-11-01 조회 2,109
10-11-01 조회 2,392
10-11-01 조회 2,606
10-10-31 조회 2,369
10-10-31 조회 2,323
10-10-31 조회 2,590
10-10-30 조회 2,000
10-10-30 조회 1,979
10-10-30 조회 2,499
10-10-30 조회 1,998
10-10-29 조회 3,167
10-10-29 조회 3,750
10-10-29 조회 2,184
10-10-29 조회 2,261
10-10-29 조회 3,137
10-10-28 조회 2,367
10-10-28 조회 2,461
10-10-28 조회 2,861
10-10-28 조회 3,014
10-10-28 조회 3,273
10-10-27 조회 2,576
10-10-27 조회 3,326