[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
0
댓글 2개
초급자분들을 위해서 간단한 함수사용방법, 그리고 어떨때 사용하면 유용한 함수인지
간략한 설명이 있으면 좋겠네요
간략한 설명이 있으면 좋겠네요
좋아요..잘쓰겠습니다.감사합니다.