그룹 최신글 입니다. 여기에 어떻게 썸네일화를 넣는 방법 알려주세요

그룹 최신글 입니다. 여기에 어떻게 썸네일화를 넣는 방법 알려주세요

QA

그룹 최신글 입니다. 여기에 어떻게 썸네일화를 넣는 방법 알려주세요

본문

여기서 사진을 썸네일화 해야 속도가 빨라진다는 것은 알았는데 아무리 해도 어떻게 넣어야 할지 모르겠습니다;;

부탁드려요 알려주세요 ㅠㅠ

http://www.hojumoney.com.au/index_test.php 

위 주소로 가시면 테스트 화면을 보실 수 있습니다.

 

lib 파일

<?

if (!defined('_GNUBOARD_')) exit;

// 함수 정의 시작

 

// 최신글 추출 - 선택한 그룹별로 원하는 게시판을 제외하고 원하는 수만큼 보여줌

function latest_group($skin_dir="", $gr_id, $rows=10, $subject_len=40, $no_table="", $category="", $orderby="")

{

global $config;

global $g4;

 

$list = array(); $limitrows = $rows;

 

$sqlgroup = " select bo_table, bo_subject from $g4[board_table] where gr_id = '$gr_id' ";

 

 

$sqlgroup .= " and bo_use_search=1 order by bo_order_search ";

$rsgroup = sql_query($sqlgroup);

 

if ($skin_dir)

$latest_skin_path = "$g4[path]/skin/$skin_dir";

else

$latest_skin_path = "$g4[path]/skin/$config[cf_latest_skin]";

 

for ($j=0, $k=0; $rowgroup=sql_fetch_array($rsgroup); $j++) {

$bo_table = $rowgroup[bo_table];

 

// 테이블 이름구함

$sql = " select * from {$g4[board_table]} where bo_table = '$bo_table'";

$board = sql_fetch($sql);

 

$tmp_write_table = $g4[write_prefix] . $bo_table; // 게시판 테이블 실제이름

 

// 옵션에 따라 정렬

$sql = "select * from $tmp_write_table where wr_is_comment = 0 ";

$sql .= (!$category) ? "" : " and ca_name = '$category' ";

$sql .= (!$orderby) ? "  order by wr_id desc " : "  order by $orderby desc, wr_id desc ";

$sql .= " limit $limitrows";

 

$result = sql_query($sql);

 

for ($i=0; $row = sql_fetch_array($result); $i++, $k++) {

 

if(!$orderby) $op_list[$k] = $row[wr_datetime];

else  {

$op_list[$k] = is_string($row[$orderby]) ? sprintf("%-256s", $row[$orderby]) : sprintf("%016d", $row[$orderby]);

$op_list[$k] .= $row[wr_datetime];

}

 

$list[$k] = get_list($row, $board, $latest_skin_path, $subject_len);

 

$list[$k][bo_table] = $board[bo_table];

$list[$k][bo_subject] = $board[bo_subject];

 

$list[$k][bo_wr_subject] = cut_str($board[bo_subject] . $list[$k][wr_subject], $subject_len);

}

}

if($k>0) array_multisort($op_list, SORT_DESC, $list);

if($k>$rows) array_splice($list, $rows);

 

ob_start();

include "$latest_skin_path/latest.skin1.php";

$content = ob_get_contents();

ob_end_clean();

return $content;

}

/// 함수 정의 끝?>

 

스킨 파일

<?

if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가 

 

$l=$i;

$l--;

?>

 

<div>

<?for ($i=0; $i<count($list); $i++) { 

if($list[$i][file][0][view]){

        $src = $list[$i][file][0][path]."/".$list[$i][file][0][file];

$img = $src;

}else{

// no 이미지를 비율적으로 만들어났음

$img = $latest_skin_path."/img/no_image.gif";

}

    

    if($i==$l){

?>

        <div class="row" id="main_news">

            <div class="col-xs-12">

                <div class="col-xs-12" id="latest_news_title">

                    <a href="<?=$list[$i]['href']?>">

                        <span>

                        <?=$list[$i]['subject']?>

                        </span>

                    </a>

                </div>

                <a href="<?=$list[$i]['href']?>">

                    <img src="<?=$img?>">

                </a>

            </div>

        </div>

 

 

<?}?>

<?}?>

<? if (count($list) == 0) {?>

<td height="50" align="center" valign="middle">게시물이 없습니다.</td>

<?}?>

</div>


이 질문에 댓글 쓰기 :

답변 2

기본 겔러리 스킨 을 이용하세요

스킨 안에보면 보드가잇고 보드안에 보면 겔러리스킨이있는데 거기 리스트에 에보면 겔러리 썸네일만드는 방법이있습니다 

님의 이전 질문 글에 

썸네일 만들기를 댓글로 달아 놓았는데, 보시지 않은 모양이네요..^^

 

스킨 파일의 내용중에, 이미지를 불러오는 내용인,

        $src = $list[$i][file][0][path]."/".$list[$i][file][0][file];

 $img = $src;

이 내용을 아래와 같이 주석처리 하고, 

      //  $src = $list[$i][file][0][path]."/".$list[$i][file][0][file];

     //  $img = $src;

다음 내용을 끼워 넣으면 될 겁니다.

---------------------------------------------------

 

$thumb_width=120;//섬네일 최대폭(원하는대로 바꾸면 됩니다.)

$thumb_height=90;//섬네일 최대높이(원하는대로 바꾸면 됩니다.)

  

 function thumbnail2($file, $save_filename, $max_width, $max_height)

 

{

        $src_img = ImageCreateFromJPEG($file); //JPG파일로부터 이미지를 읽어옵니다

  

        $img_info = getImageSize($file);//원본이미지의 정보를 얻어옵니다

        $img_width = $img_info[0];

        $img_height = $img_info[1];

  

        if(($img_width/$max_width) == ($img_height/$max_height))

        {//원본과 썸네일의 가로세로비율이 같은경우

            $dst_width=$max_width;

           $dst_height=$max_height;

 

        }

 

        elseif(($img_width/$max_width) < ($img_height/$max_height))

        {//세로에 기준을 둔경우

            $dst_width=$max_height*($img_width/$img_height);

            $dst_height=$max_height;

        }

  

        else

 

        {//가로에 기준을 둔경우

            $dst_width=$max_width;

            $dst_height=$max_width*($img_height/$img_width);

        }

 

  

  

        $dst_img = imagecreatetruecolor($dst_width, $dst_height); //타겟이미지를 생성합니다

   

 

        ImageCopyResized($dst_img, $src_img, 0, 0, 0, 0, $dst_width, $dst_height, $img_width, $img_height); //타겟이미지에 원하는 사이즈의 이미지를 저장합니다

 

    

        ImageInterlace($dst_img);

        ImageJPEG($dst_img,  $save_filename); //실제로 이미지파일을 생성합니다

        ImageDestroy($dst_img);

        ImageDestroy($src_img);

 

}

 

  

 

                        $image = $list[$i][file][0][file]; //공백으로인한썸네일깨짐방지

 

                            if (preg_match("/\.(gif|jpg|png)$/i", $image)) {

  

                            $thumbdir = $g4[path]."/data/file/".$bo_table ;

  

                            $thumbsource="$g4[path]/data/file/$bo_table/" . $image;

                            $thumbimg = $thumbdir."/".$list[$i][wr_id].".thumb";

 

              thumbnail2($tmpfile, $src, $tmpsize0, $tmpsize1);     

                            @chmod($thumbimg, 0707);

   

             } 

 

 

$img = $thumbimg;

--------------------------------------------------- 

이 내용은 jpeg(jpg)의 썸네일 생성입니다.

 

gif, png 의 경우도 거의 같습니다.

(ImageCreateFromJPEG --> 이부분만 달라지면 됩니다.)

다만, 첨부파일의 확장자를 확인하는 작업이 더 들어가야 겠지요.^^


답변을 작성하시기 전에 로그인 해주세요.
전체 10,633
QA 내용 검색

회원로그인

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