이미지 출력관련 질문 드립니다.

매출이 오르면 내리는 수수료! 지금 수수료센터에서 전자결제(PG)수수료 비교견적 신청해 보세요!
이미지 출력관련 질문 드립니다.

QA

이미지 출력관련 질문 드립니다.

본문

안녕하세요 현재 스마트에디터2 사용중에 있습니다.

스마트 에디터로 이미지를 업로드 하고

VIEW에서 보여지는건 1개씩 쭉 나열하는게 아니라 한줄에 2개씩 보이고 싶게 하고 싶습니다

이게 썸네일 생성 함수 부분을 만져야할거같은데 어디서 어떻게 수정을 해야할지 감이 오지 않아서 질문드립니다. 감사합니다.

 

//썸네일 생성 함수

function get_view_thumbnail($contents, $thumb_width=0)

{

    global $board, $config;

 

    if (!$thumb_width)

        $thumb_width = $board['bo_image_width'];

 

    // $contents 중 img 태그 추출

    $matches = get_editor_image($contents, true);

 

    if(empty($matches))

        return $contents;

 

    for($i=0; $i<count($matches[1]); $i++) {

 

        $img = $matches[1][$i];

        preg_match("/src=[\'\"]?([^>\'\"]+[^>\'\"]+)/i", $img, $m);

        $src = $m[1];

        preg_match("/style=[\"\']?([^\"\'>]+)/i", $img, $m);

        $style = $m[1];

        preg_match("/width:\s*(\d+)px/", $style, $m);

        $width = $m[1];

        preg_match("/height:\s*(\d+)px/", $style, $m);

        $height = $m[1];

        preg_match("/alt=[\"\']?([^\"\']*)[\"\']?/", $img, $m);

        $alt = get_text($m[1]);

 

        // 이미지 path 구함

        $p = parse_url($src);

        if(strpos($p['path'], '/'.G5_DATA_DIR.'/') != 0)

            $data_path = preg_replace('/^\/.*\/'.G5_DATA_DIR.'/', '/'.G5_DATA_DIR, $p['path']);

        else

            $data_path = $p['path'];

 

        $srcfile = G5_PATH.$data_path;

 

        if(is_file($srcfile)) {

            $size = @getimagesize($srcfile);

            if(empty($size))

                continue;

 

            // jpg 이면 exif 체크

            if($size[2] == 2 && function_exists('exif_read_data')) {

                $degree = 0;

                $exif = @exif_read_data($srcfile);

                if(!empty($exif['Orientation'])) {

                    switch($exif['Orientation']) {

                        case 8:

                            $degree = 90;

                            break;

                        case 3:

                            $degree = 180;

                            break;

                        case 6:

                            $degree = -90;

                            break;

                    }

 

                    // 세로사진의 경우 가로, 세로 값 바꿈

                    if($degree == 90 || $degree == -90) {

                        $tmp = $size;

                        $size[0] = $tmp[1];

                        $size[1] = $tmp[0];

                    }

                }

            }

 

            // 원본 width가 thumb_width보다 작다면

            if($size[0] <= $thumb_width)

                continue;

 

            // Animated GIF 체크

            $is_animated = false;

            if($size[2] == 1) {

                $is_animated = is_animated_gif($srcfile);

            }

 

            // 썸네일 높이

            $thumb_height = round(($thumb_width * $size[1]) / $size[0]);

            $filename = basename($srcfile);

            $filepath = dirname($srcfile);

 

            // 썸네일 생성

            if(!$is_animated)

                $thumb_file = thumbnail($filename, $filepath, $filepath, $thumb_width, $thumb_height, false);

            else

                $thumb_file = $filename;

 

            if(!$thumb_file)

                continue;

 

            if ($width) {

                $thumb_tag = '<img src="'.G5_URL.str_replace($filename, $thumb_file, $data_path).'" alt="'.$alt.'" width="'.$width.'" height="'.$height.'"/>';

            } else {

                $thumb_tag = '<img src="'.G5_URL.str_replace($filename, $thumb_file, $data_path).'" alt="'.$alt.'"/>';

            }

 

            // $img_tag에 editor 경로가 있으면 원본보기 링크 추가

            $img_tag = $matches[0][$i];

            if(strpos($img_tag, G5_DATA_DIR.'/'.G5_EDITOR_DIR) && preg_match("/\.({$config['cf_image_extension']})$/i", $filename)) {

                $imgurl = str_replace(G5_URL, "", $src);

                $thumb_tag = '<a href="'.G5_BBS_URL.'/view_image.php?fn='.urlencode($imgurl).'" target="_blank" class="view_image">'.$thumb_tag.'</a>';

            }

 

            $contents = str_replace($img_tag, $thumb_tag, $contents);

        }

    }

 

    return run_replace('get_view_thumbnail', $contents);

}

 

 

 


//본문 부분

        <div id="bo_v_con">

            <?php

            echo get_view_thumbnail($view['content']); ?>

        </div>
 

이 질문에 댓글 쓰기 :

답변 1

답변을 작성하시기 전에 로그인 해주세요.
전체 0
QA 내용 검색
  • 개별 목록 구성 제목 답변작성자조회작성일
  • 질문이 없습니다.

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT