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건
+
제목 글쓴이 날짜 조회
16-07-13 조회 2,185
16-07-12 조회 2,371
16-07-12 조회 2,397
16-07-11 조회 2,223
16-06-05 조회 2,943
16-06-03 조회 3,084
16-05-26 조회 3,012
15-09-22 조회 5,015
15-06-10 조회 4,860
14-10-25 조회 6,389
14-10-22 조회 9,005
14-09-21 조회 5,825
14-09-16 조회 5,099
14-08-22 조회 1.1만
14-08-13 조회 5,951
14-08-12 조회 5,455
14-08-12 조회 6,334
14-08-11 조회 6,969
14-06-12 조회 6,242
14-06-11 조회 5,132
14-05-09 조회 5,476
14-05-09 조회 6,430
14-05-09 조회 6,451
14-05-08 조회 5,797
14-04-17 조회 4,802
14-04-16 조회 4,617
14-04-15 조회 4,614
14-04-15 조회 4,556
14-04-15 조회 4,330
14-04-14 조회 4,322
14-04-14 조회 4,296
14-04-14 조회 4,656
14-04-14 조회 4,808
14-04-14 조회 4,798
14-04-13 조회 4,714
14-04-12 조회 4,265
14-04-12 조회 4,405
14-04-12 조회 4,506
14-04-11 조회 5,024
14-04-10 조회 4,778
14-04-10 조회 4,808
14-04-09 조회 4,959
14-04-09 조회 5,347
14-04-08 조회 7,028
13-10-30 조회 7,682
13-07-11 조회 5,169
13-03-28 조회 1.1만
13-02-27 조회 6,808
13-02-14 조회 5,664
13-01-10 조회 4,544
12-12-31 조회 5,135
12-12-20 조회 6,138
12-12-12 조회 5,302
12-12-07 조회 4,545
12-11-28 조회 4,912
12-11-22 조회 5,339
12-11-12 조회 5,711
12-09-22 조회 4,540
12-09-18 조회 4,728