R

이미지 리사이즈 jQuery 로 변경 방법

· 2009-01-20 (화) 13:50:37 · 4247 · 1
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,188건
+
제목 글쓴이 날짜 조회
10-09-25 조회 2,715
10-09-19 조회 2,752
10-09-15 조회 2,754
10-09-15 조회 4,157
10-09-15 조회 3,373
10-09-15 조회 2,489
10-09-07 조회 3,599
10-08-27 조회 4,061
10-06-11 조회 4,222
10-05-31 조회 2,472
10-02-27 조회 4,998
10-02-09 조회 3,748
09-10-10 조회 7,339
09-03-19 조회 3,182
09-02-09 조회 3,460
09-02-09 조회 4,531
08-11-01 조회 2,906
08-09-29 조회 4,559
08-09-26 조회 3,511
08-09-26 조회 3,589
08-09-26 조회 2,724
08-09-26 조회 3,768
08-09-26 조회 3,492
08-09-26 조회 4,253
08-09-18 조회 3,570
08-09-09 조회 3,225
08-08-28 조회 2,767
08-07-06 조회 3,539
08-05-21 조회 4,700
08-05-13 조회 4,535
08-04-17 조회 4,914
08-02-19 조회 3,535
08-01-18 조회 3,841
08-01-10 조회 3,814
07-10-22 조회 3,653
07-10-09 조회 4,305
07-10-03 조회 3,511
07-07-06 조회 4,211
07-07-06 조회 4,425
07-07-06 조회 4,035
07-06-28 조회 3,564
07-06-05 조회 3,564
07-06-05 조회 4,112
07-05-30 조회 3,285
07-05-02 조회 3,685
07-04-15 조회 5,143
07-04-11 조회 3,628
07-04-05 조회 3,926
07-03-31 조회 3,148
07-03-31 조회 4,122
07-03-30 조회 3,729
07-03-24 조회 4,000
07-03-22 조회 3,657
07-03-12 조회 4,406
07-02-16 조회 3,268
07-02-14 조회 5,165
07-02-10 조회 3,994
07-02-09 조회 4,377
07-01-19 조회 4,044
07-01-16 조회 4,972
06-12-16 조회 5,835
06-11-30 조회 3,599
06-11-25 조회 3,700
06-10-15 조회 5,065
06-09-26 조회 5,308
06-09-26 조회 5,425
06-09-22 조회 4,267
06-09-21 조회 3,542
06-09-21 조회 3,632
06-09-02 조회 3,484
06-08-08 조회 5,114
06-07-20 조회 3,718
06-07-17 조회 3,348
06-07-13 조회 4,171
06-07-11 조회 3,470
06-07-11 조회 3,476
06-07-11 조회 3,835
06-06-29 조회 6,054
06-06-19 조회 6,454
06-06-02 조회 3,508
06-05-24 조회 4,994
06-05-14 조회 7,775
06-05-08 조회 3,883
06-02-02 조회 5,451
05-12-16 조회 4,501
05-12-05 조회 5,154
05-06-28 조회 4,105
05-04-11 조회 4,061
05-04-11 조회 4,248
05-04-11 조회 3,315
05-03-13 조회 3,218
05-03-12 조회 4,296
04-12-08 조회 7,778
04-12-01 조회 5,182
04-11-28 조회 3,357
04-11-28 조회 3,197
04-08-05 조회 5,612
04-08-05 조회 4,964
04-08-05 조회 5,569