그림자밟기

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

· 2017-10-12 (목) 15:10:29 · 7332 · 2
[code]
<?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>';
}
?>
[/code]

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

댓글 2개

초급자분들을 위해서 간단한 함수사용방법, 그리고 어떨때 사용하면 유용한 함수인지
간략한 설명이 있으면 좋겠네요
좋아요..잘쓰겠습니다.감사합니다.
댓글을 작성하시려면 로그인이 필요합니다.

그누보드5 팁자료실

2,788건
+
제목 글쓴이 날짜 조회
17-11-05 조회 1.3만
17-11-05 조회 2만
17-11-03 조회 6,784
17-11-03 조회 7,889
17-11-03 조회 6,219
17-11-02 조회 7,596
17-11-01 조회 7,852
17-11-01 조회 4,883
17-11-01 조회 9,173
17-10-21 조회 8,359
17-10-21 조회 6,194
17-10-21 조회 1.4만
17-10-17 조회 5,824
17-10-16 조회 8,341
17-10-12 조회 6,175
17-10-12 조회 7,333
17-10-12 조회 7,819
17-10-10 조회 7,557
17-10-10 조회 8,494
17-10-08 조회 7,661
17-10-05 조회 5,987
17-10-04 조회 1.1만
17-10-02 조회 6,331
17-10-02 조회 5,941
17-10-01 조회 6,891
17-09-29 조회 5,972
17-09-29 조회 8,103
17-09-28 조회 7,523
17-09-27 조회 6,382
17-09-25 조회 5,917