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,152
16년 전 조회 2,112
16년 전 조회 2,085
16년 전 조회 1,623
16년 전 조회 2,174
16년 전 조회 2,388
16년 전 조회 1,496
16년 전 조회 1,857
16년 전 조회 2,034
16년 전 조회 1,120
16년 전 조회 1,819
16년 전 조회 1,504
16년 전 조회 2,017
16년 전 조회 1,427
16년 전 조회 2,319
16년 전 조회 2,004
16년 전 조회 6,001
16년 전 조회 2,022
16년 전 조회 3,799
16년 전 조회 1,565
16년 전 조회 1,854
16년 전 조회 2,204
16년 전 조회 2,729
16년 전 조회 2,425
16년 전 조회 2,859
16년 전 조회 3,105
16년 전 조회 3,119
16년 전 조회 1,925
16년 전 조회 1,649
17년 전 조회 1,511
17년 전 조회 1,830
17년 전 조회 1,316
17년 전 조회 2,076
17년 전 조회 1,846
17년 전 조회 1,713
17년 전 조회 1,403
17년 전 조회 2,288
17년 전 조회 3,345
17년 전 조회 2,265
17년 전 조회 1,851
17년 전 조회 1,625
17년 전 조회 2,154
17년 전 조회 4,835
17년 전 조회 1,547
17년 전 조회 2,288
17년 전 조회 2,264
17년 전 조회 2,536
17년 전 조회 2,249
17년 전 조회 4,565
17년 전 조회 3,065
17년 전 조회 2,982
17년 전 조회 1,698
17년 전 조회 1,345
17년 전 조회 4,089
17년 전 조회 1,748
17년 전 조회 1,744
17년 전 조회 2,230
17년 전 조회 1,981
17년 전 조회 1,630
17년 전 조회 4,051
17년 전 조회 1,877
17년 전 조회 3,228
17년 전 조회 3,133
17년 전 조회 1,138
17년 전 조회 1,962
17년 전 조회 1,706
17년 전 조회 1,956
17년 전 조회 2,763
17년 전 조회 3,139
17년 전 조회 3,338
17년 전 조회 3,453
17년 전 조회 1,565
17년 전 조회 1,533
17년 전 조회 2,358
17년 전 조회 2,095
17년 전 조회 2,395
17년 전 조회 2,923
17년 전 조회 3,392
17년 전 조회 2,489
17년 전 조회 1,763
17년 전 조회 3,331
17년 전 조회 3,190
17년 전 조회 3,164
17년 전 조회 4,039
17년 전 조회 2,689
17년 전 조회 2,522
17년 전 조회 2,776
17년 전 조회 3,018
17년 전 조회 2,736
17년 전 조회 1,566
17년 전 조회 1,994
17년 전 조회 1,596
17년 전 조회 2,034
17년 전 조회 2,631
17년 전 조회 8,801
17년 전 조회 3,269
17년 전 조회 4,345
17년 전 조회 2,100
17년 전 조회 3,773
17년 전 조회 1,675