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,114
16년 전 조회 2,068
16년 전 조회 2,040
16년 전 조회 1,572
16년 전 조회 2,101
16년 전 조회 2,341
16년 전 조회 1,452
16년 전 조회 1,798
16년 전 조회 1,981
16년 전 조회 1,071
16년 전 조회 1,753
16년 전 조회 1,461
16년 전 조회 1,967
16년 전 조회 1,374
16년 전 조회 2,265
16년 전 조회 1,957
16년 전 조회 5,927
16년 전 조회 1,975
16년 전 조회 3,742
16년 전 조회 1,531
16년 전 조회 1,816
16년 전 조회 2,127
16년 전 조회 2,671
16년 전 조회 2,372
16년 전 조회 2,805
16년 전 조회 3,048
16년 전 조회 3,073
16년 전 조회 1,880
16년 전 조회 1,598
16년 전 조회 1,468
16년 전 조회 1,787
16년 전 조회 1,264
16년 전 조회 2,028
16년 전 조회 1,798
17년 전 조회 1,668
17년 전 조회 1,351
17년 전 조회 2,228
17년 전 조회 3,290
17년 전 조회 2,216
17년 전 조회 1,799
17년 전 조회 1,567
17년 전 조회 2,096
17년 전 조회 4,786
17년 전 조회 1,477
17년 전 조회 2,203
17년 전 조회 2,181
17년 전 조회 2,458
17년 전 조회 2,204
17년 전 조회 4,486
17년 전 조회 2,991
17년 전 조회 2,934
17년 전 조회 1,653
17년 전 조회 1,300
17년 전 조회 4,014
17년 전 조회 1,676
17년 전 조회 1,675
17년 전 조회 2,169
17년 전 조회 1,946
17년 전 조회 1,568
17년 전 조회 3,978
17년 전 조회 1,815
17년 전 조회 3,192
17년 전 조회 3,062
17년 전 조회 1,093
17년 전 조회 1,907
17년 전 조회 1,663
17년 전 조회 1,910
17년 전 조회 2,694
17년 전 조회 3,087
17년 전 조회 3,272
17년 전 조회 3,378
17년 전 조회 1,522
17년 전 조회 1,479
17년 전 조회 2,311
17년 전 조회 2,034
17년 전 조회 2,355
17년 전 조회 2,873
17년 전 조회 3,324
17년 전 조회 2,420
17년 전 조회 1,689
17년 전 조회 3,268
17년 전 조회 3,125
17년 전 조회 3,107
17년 전 조회 3,970
17년 전 조회 2,643
17년 전 조회 2,461
17년 전 조회 2,710
17년 전 조회 2,953
17년 전 조회 2,669
17년 전 조회 1,506
17년 전 조회 1,948
17년 전 조회 1,537
17년 전 조회 1,970
17년 전 조회 2,568
17년 전 조회 8,748
17년 전 조회 3,214
17년 전 조회 4,304
17년 전 조회 2,046
17년 전 조회 3,722
17년 전 조회 1,618