[100원팁] 전체 게시물 첨부 파일중 이미지 썸네일 추출 > 그누보드5 팁자료실

그누보드5 팁자료실

[100원팁] 전체 게시물 첨부 파일중 이미지 썸네일 추출 정보

[100원팁] 전체 게시물 첨부 파일중 이미지 썸네일 추출

본문


<?php
// 썸네일 추출 함수
function get_all_thumbnail($cnt, $thumb_width, $thumb_height, $is_create=false, $is_crop=true, $crop_mode='center', $is_sharpen=false, $um_value='80/0.5/3')
{
    global $g5, $config;
    $filename = $alt = "";
    $edt = false;
    $cnt = $cnt + 0;
    if(!$cnt) return false;
    $sql = " select bo_table, wr_id, bf_file, bf_content from {$g5['board_file_table']}
                where bf_type between '1' and '3' group by bo_table, wr_id order by bf_datetime desc, bf_no limit 0, {$cnt} ";
    $result = sql_query($sql);
    $thumb = array();
    while($row = sql_fetch_array($result)) {
        $bo_table = $row['bo_table'];
        $wr_id = $row['wr_id'];
        if($row['bf_file']) {
            $filename = $row['bf_file'];
            $filepath = G5_DATA_PATH.'/file/'.$bo_table;
            $alt = get_text($row['bf_content']);
        }

        if(!$filename)
            return false;

        $tname = thumbnail($filename, $filepath, $filepath, $thumb_width, $thumb_height, $is_create, $is_crop, $crop_mode, $is_sharpen, $um_value);

        if($tname) {
            if($edt) {
                // 오리지날 이미지
                $ori = G5_URL.$data_path;
                // 썸네일 이미지
                $src = G5_URL.str_replace($filename, $tname, $data_path);
            } else {
                $ori = G5_DATA_URL.'/file/'.$bo_table.'/'.$filename;
                $src = G5_DATA_URL.'/file/'.$bo_table.'/'.$tname;
            }
        } else {
            return false;
        }

        $thumb[] = array("src"=>$src, "ori"=>$ori, "alt"=>$alt, "bo_table"=>$bo_table, "wr_id"=>$wr_id);
    }
    return $thumb;
}

// 예시
$all_img = get_all_thumbnail(5, 200, 200);
foreach($all_img as $v) {
    echo '<a href="'.G5_BBS_URL.'/board.php?bo_table='.$v['bo_table'].'&wr_id='.$v['wr_id'].'"><img src="'.$v['src'].'"></a>';
}
?>


* 기존 썸네일 함수 파일에 추가해서 사용하면 됩니다.
추천
0

댓글 2개

초급자분들을 위해서 간단한 함수사용방법, 그리고 어떨때 사용하면 유용한 함수인지
간략한 설명이 있으면 좋겠네요
전체 2,431 |RSS
그누보드5 팁자료실 내용 검색

회원로그인

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