이번에 작업 진행하면서 sir에서 여러 팁을 참조해 작업을 해 보았는데요..
제대로 작동하는 팁이 없어서 짜집기 신공을 발휘해 만들어 보았습니다..
본 내용은 이미지를 1개 게시글에 다량 등록하구요
그 다량 등록된 이미지를 리스트에서 바로볼 수 있게 구현하기 위한
썸네일 생성 방법입니다.
1. thumbnail.lib.php에 추가합니다.
function get_list_thumbnail_all($ori_filename, $bo_table, $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;
if($ori_filename) {
$filename = $ori_filename;
$filepath = G5_DATA_PATH.'/file/'.$bo_table;
}
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);
return $thumb;
}
2. get_list_thumbnail_all 에 사용될 전달인자는 다음과 같습니다.
get_list_thumbnail_all(원본파일명, 게시판명, 썸네일 생성 가로폭, 썸네일 생성 세로폭);
3. list.skin.php에 추가하기
$sql = " select * from {$g5['board_file_table']} where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no ";
$result = sql_query($sql);
while ($row = sql_fetch_array($result))
{
if($row['bf_type'] > 0 && $row['bf_type'] <= 3) {
$thumb_file = get_list_thumbnail_all($row['bf_file'], $bo_table ,$board['bo_gallery_width'], $board['bo_gallery_height'], false);
?>
<img src="<?=$thumb_file['src']?>">
<?php
}
} ?>
매번 작업량이 많아서 시간에 쫒겨 짜깁기를 해서 해결하곤 있는데
그누보드에 사용된 라이브러리나 함수들을 보면 참 대단하단 생각이 많이 듭니다.
함수를 보시면 기존에 있던 get_list_thumbnail 함수를 바탕으로 sql문을 리스트에서실행하는
부분만 바뀌었고 다른부분은 사용법또한 동일합니다 src나 ori나 alt등...
알트 태그는 제가 지금 진행하고 있는작업에선 크게 의미가 없어서 마무리를 다 못했네요
필요에 따라서 추가 작업하시면 될겁니다.
다른 저와 같이 시간이 많이 부족하신분께 도움이 되길 바랍니다.
댓글 7개
thumbnail.lib.php 에는 추가만 하면 되구,
$sql = " select * from {$g5['board_file_table']} where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no ";
$result = sql_query($sql);
얘들은 <?php ?>
이 사이에 넣으면 되고
while ($row = sql_fetch_array($result))
{
if($row['bf_type'] > 0 && $row['bf_type'] <= 3) {
$thumb_file = get_list_thumbnail_all($row['bf_file'], $bo_table ,$board['bo_gallery_width'], $board['bo_gallery_height'], false);
이녀석은 게시글에 나오는 이미지쪽에 넣으면 될까요?
썸네일을 생성을 못하네요 ㅠ.ㅠ
이것만 되면 최신게시글도 한게시물당 여러이미지를 불러올수 있을거같은데 ㅠㅠ
게시글 목록
| 번호 | 제목 |
|---|---|
| 24318 | |
| 24317 | |
| 24315 | |
| 24309 | |
| 24294 | |
| 24293 | |
| 24277 | |
| 24262 | |
| 24260 | |
| 24253 | |
| 24251 | |
| 24236 | |
| 24233 | |
| 24228 | |
| 24226 | |
| 24221 | |
| 24214 | |
| 24203 | |
| 24201 | |
| 24199 | |
| 24196 | |
| 24195 | |
| 24194 | |
| 24192 | |
| 24191 | |
| 24187 | |
| 24185 | |
| 24183 | |
| 24172 | |
| 24168 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기