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건
+
제목 글쓴이 날짜 조회
07-10-19 조회 3,492
07-10-19 조회 3,245
07-10-19 조회 3,197
07-10-19 조회 2,897
07-10-19 조회 4,471
07-10-19 조회 5,837
07-10-19 조회 6,122
07-10-19 조회 3,512
07-10-19 조회 4,971
07-10-17 조회 4,625
07-10-17 조회 6,013
07-10-16 조회 4,638
07-10-15 조회 5,601
07-10-13 조회 5,273
07-10-09 조회 4,975
07-10-09 조회 4,312
07-10-09 조회 4,238
07-10-09 조회 4,798
07-10-09 조회 3,566
07-10-09 조회 3,349
07-10-09 조회 6,816
07-10-09 조회 3,965
07-10-09 조회 3,707
07-10-09 조회 4,030
07-10-09 조회 3,402
07-10-09 조회 4,444
07-10-08 조회 1.1만
07-10-05 조회 3,170
07-10-05 조회 4,096
07-10-03 조회 4,226
07-10-03 조회 3,418
07-10-03 조회 4,266
07-10-03 조회 5,283
07-10-03 조회 4,268
07-10-03 조회 3,665
07-10-03 조회 7,357
07-10-03 조회 4,935
07-10-03 조회 7,604
07-10-03 조회 3,702
07-10-03 조회 3,651
07-10-03 조회 3,644
07-10-03 조회 4,686
07-10-03 조회 4,649
07-10-03 조회 3,340
07-10-03 조회 5,197
07-10-03 조회 3,007
07-10-03 조회 2,669
07-10-03 조회 2,723
07-10-03 조회 2,932
07-10-03 조회 2,932
07-10-03 조회 4,753
07-10-02 조회 3,644
07-10-02 조회 3,175
07-10-02 조회 3,508
07-10-02 조회 5,813
07-10-02 조회 3,552
07-10-02 조회 4,170
07-10-02 조회 3,188
07-10-02 조회 4,854
07-10-02 조회 3,107
07-10-02 조회 8,941
07-10-02 조회 4,594
07-10-01 조회 2,556
07-10-01 조회 3,759
07-09-28 조회 4,775
07-09-28 조회 3,651
07-09-27 조회 3,553
07-09-27 조회 4,060
07-09-27 조회 5,110
07-09-27 조회 4,709
07-09-27 조회 3,848
07-09-27 조회 3,255
07-09-27 조회 3,304
07-09-27 조회 3,943
07-09-27 조회 3,273
07-09-15 조회 4,218
07-09-15 조회 2,931
07-09-13 조회 3,446
07-09-13 조회 2,965
07-09-13 조회 3,417
07-09-11 조회 3,645
07-09-09 조회 3,581
07-08-28 조회 3,516
07-08-28 조회 3,392
07-08-23 조회 4,696
07-08-22 조회 2,882
07-08-21 조회 4,671
07-08-21 조회 3,253
07-08-16 조회 6,521
07-08-07 조회 3,440
07-08-04 조회 3,567
07-08-04 조회 2,936
07-08-04 조회 3,344
07-08-04 조회 4,900
07-08-04 조회 2,747
07-08-04 조회 2,952
07-08-01 조회 5,586
07-08-01 조회 5,009
07-07-31 조회 4,475
07-07-31 조회 4,715