모든 게시판 이미지 추출하기 스킨에서 섬네일로 보여주는 방법..? 정보
모든 게시판 이미지 추출하기 스킨에서 섬네일로 보여주는 방법..?관련링크
본문
모든 게시판의 이미지를 추출하여 보여주는 스킨입니다.
근데 전부 오리지날 파일을 리사이즈해서 보여주는 스킨이더군여.
부하가 넘심해서 섬네일을 불러와서 보여주는것으로 변경도전을 해봤는데 실패....ㅠㅠ
도움주실 분 있으신가요?
근데 전부 오리지날 파일을 리사이즈해서 보여주는 스킨이더군여.
부하가 넘심해서 섬네일을 불러와서 보여주는것으로 변경도전을 해봤는데 실패....ㅠㅠ
도움주실 분 있으신가요?
댓글 전체
저도 오리지날 파일만 불러오는 문제가 있어서
그냥 이미지 불러오는 방식을 바꿔버렸어요..
$img_file = "{$list[$i][file][0][path]}/{$list[$i][file][0][file]}";
echo "<img src={$img_file} width=150 height=80 >
이런식으로 그냥 등록 된 이미지 불러와서 싸이즈 정해주고 출력을하죠..
그냥 이미지 불러오는 방식을 바꿔버렸어요..
$img_file = "{$list[$i][file][0][path]}/{$list[$i][file][0][file]}";
echo "<img src={$img_file} width=150 height=80 >
이런식으로 그냥 등록 된 이미지 불러와서 싸이즈 정해주고 출력을하죠..
image_all.php파일입니다....
대충 썸넬 만들어지는거 확인했구요....
시간이 없어서 정확히 체크는 못해봤음니당~~~~~~~~오류 좀 나는거 수정...하실수 있으시겠죠;;
안되면 제가 월욜날쯤에 다시 수정해드리겠습니다....쪽지주셈요...수정후 스킨게시판에올리셔도 상관없음요~~ㅋ
<?
include_once("./_common.php");
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
include_once("$g4[path]/_head.php");
////////////////basic cf control///////////
$g4[g4_board_file] = "g4_board_file"; // $g4['table_prefix']경로확인~
$one_rows = "25"; // 이미지 출력수량
$width_o = "120"; //이미지 가로값
$height_o = "100"; //이미지 세로값
$cols = "5"; // 이미지 가로갯수
$image_h = "17"; // 이미지 상하 간격
//jpg, jpeg, gif, png 파일만 검색한다.
$one_like = " bf_file LIKE '%jpg' or bf_file LIKE '%jpeg' or bf_file LIKE '%gif' or bf_file LIKE '%png' ";
$one_count_sql = " select count(*) as cnt from $g4[g4_board_file] where $one_like ";
$row = sql_fetch($one_count_sql);
$total_count = $row[cnt];
$total_page = ceil($total_count / $one_rows); // 전체 페이지 계산
if ($page == "") { $page = 1; } // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $one_rows; // 시작 열을 구함
$to_record = $from_record + $one_rows ;
$one_sql = " select * from $g4[g4_board_file] where $one_like order by bf_datetime desc limit $from_record, $one_rows";
$one_result = sql_query($one_sql);
?>
<!----------Zzzzzzzzzzzzzzzzzzz-------->
<?
$thumb_path = $g4[path]."/data/file/thumb";
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
?>
<!-----------Zzzzzzzzzzzzzzzz--------->
<!-----------기간별 출력시작--------->
<table width=100% cellpadding=0 cellspacing=0>
<tr><td height="4"></td></tr>
<tr><td align=left><font style="font-size:12pt;"><b>이미지</b> (총 <?=$total_count?>개중 <?=$from_record+1?> -
<?
if (($from_record + ($one_rows-1)) < $total_count) {
echo "{$to_record}";
} else {
echo "{$total_count}";
}
?>)
</font>
</td></tr>
<tr><td height="10"></td></tr>
<tr><td height=1 bgcolor=#E7E7E7></td></tr>
<tr><td height="10"></td></tr>
</table>
<table width=100% cellpadding=0 cellspacing=0>
<tr>
<?//출력
for ($i=0; $one_row = sql_fetch_array($one_result); $i++){
if ($i>0 && $i%$cols==0) { echo "</tr><tr><td colspan='$cols' height='$image_h'></td></tr><tr>"; }
//<!-----------Zzzzzzzzzzzzzzzz--------->
$data_path = $g4[path]."/data/file/".$one_row[bo_table];
$thumb = $thumb_path.'/'.$one_row[bo_table]."_".$one_row[wr_id];
// 썸네일 이미지가 존재하지 않는다면
if (!file_exists($thumb))
{
$file = $data_path."/".$one_row[bf_file];
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($file))
{
$size = getimagesize($file);
if ($size[2] == 1)
$src = imagecreatefromgif($file);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($file);
else if ($size[2] == 3)
$src = imagecreatefrompng($file);
else
break;
$rate = $height_o / $size[1];
$width = (int)($size[0] * $rate);
//echo "rate : $rate ,width : $width, $height : $board[bo_2] <br>";
if($width <= $width_o) { //width가 지정된 사이즈보다 작을경우 rate 비율로 썸네일 생성
$dst = imagecreatetruecolor($width, $height_o);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $width, $height_o , $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$one_row[wr_id], $height_o );
}
else {
$rate = $width_o / $size[0];
$height = (int)($size[1] * $rate);
$dst = imagecreatetruecolor($width_o, $height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $width_o, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$one_row[bo_table]."_".$one_row[wr_id], $height_o);
}
chmod($thumb_path.'/'.$one_row[bo_table]."_".$one_row[wr_id], 0606);
}
}
if (file_exists($thumb)){
$img[$i] = "<img src='$thumb' border='0' alt='' />";
}
//<!-----------Zzzzzzzzzzzzzzzz--------->
if ($one_row[bf_width] > $one_row[bf_height]) {
$width_i1 = $width_o;
$height_i1 = ($one_row[bf_height] * $width_o) / $one_row[bf_width] ;
if ($height_i1 > $height_o) {
$width_i = ($width_i1 * $height_o) / $height_i1;
$height_i = $height_o;
} else {
$width_i = $width_i1;
$height_i = $height_i1;
}
} else if ($one_row[bf_width] < $one_row[bf_height]) {
$width_i = ($one_row[bf_width] * $height_o) / $one_row[bf_height];
$height_i = $height_o;
} else {
$width_i = $height_o;
$height_i = $height_o;
}
?>
<td valign=top align="center" width="150">
<table width="140" height="120" border="0" cellpadding="0" cellspacing="0" bgcolor='#ECECEC' onMouseOver="bgColor='#71AEFE'" onMouseOut="bgColor='#ECECEC'">
<tr><td align="center"><table bgcolor="#FFFFFF" width="136" height="116" border="0" cellpadding="0" cellspacing="0">
<tr><td align="center"><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$one_row[bo_table]?>&wr_id=<?=$one_row[wr_id]?>' onfocus='this.blur()'><?=$img[$i]?></a></td></tr>
</table></td></tr>
</table>
<table width=140 cellpadding=0 cellspacing=0><tr><td height="5"></td></tr><tr><td align="left">
<?
$sql = " select wr_subject from $g4[write_prefix]$one_row[bo_table] where wr_id = '$one_row[wr_id]' ";
$row = sql_fetch($sql);
$sql2 = " select bo_subject from $g4[board_table] where bo_table = '$one_row[bo_table]' ";
$row2 = sql_fetch($sql2);
?>
<a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$one_row[bo_table]?>&wr_id=<?=$one_row[wr_id]?>' onfocus='this.blur()'><b><u><?=cut_str($row[wr_subject], 16)?></u></a></td></tr>
<tr><td height="5"></td></tr>
<tr><td align="left"> <?=$row2[bo_subject]?></td></tr>
</table>
</td>
<? } ?>
</tr>
<tr><td width="150" height="10"></td><td width="150" height="10"></td><td width="150" height="10"></td><td width="150" height="10"></td><td width="150" height="10"></td></tr>
</table>
<table width=100% cellpadding=0 cellspacing=0>
<tr><td height=1 bgcolor=#E7E7E7></td></tr>
<tr><td height="10"></td></tr>
<tr><td>
<?
$page = get_paging($config[cf_write_pages], $page, $total_page, "?&page=");
echo "$page";
?>
</td></tr>
<tr><td height="10"></td></tr>
</table>
<?
include_once("$g4[path]/_tail.php");
?>
대충 썸넬 만들어지는거 확인했구요....
시간이 없어서 정확히 체크는 못해봤음니당~~~~~~~~오류 좀 나는거 수정...하실수 있으시겠죠;;
안되면 제가 월욜날쯤에 다시 수정해드리겠습니다....쪽지주셈요...수정후 스킨게시판에올리셔도 상관없음요~~ㅋ
<?
include_once("./_common.php");
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
include_once("$g4[path]/_head.php");
////////////////basic cf control///////////
$g4[g4_board_file] = "g4_board_file"; // $g4['table_prefix']경로확인~
$one_rows = "25"; // 이미지 출력수량
$width_o = "120"; //이미지 가로값
$height_o = "100"; //이미지 세로값
$cols = "5"; // 이미지 가로갯수
$image_h = "17"; // 이미지 상하 간격
//jpg, jpeg, gif, png 파일만 검색한다.
$one_like = " bf_file LIKE '%jpg' or bf_file LIKE '%jpeg' or bf_file LIKE '%gif' or bf_file LIKE '%png' ";
$one_count_sql = " select count(*) as cnt from $g4[g4_board_file] where $one_like ";
$row = sql_fetch($one_count_sql);
$total_count = $row[cnt];
$total_page = ceil($total_count / $one_rows); // 전체 페이지 계산
if ($page == "") { $page = 1; } // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $one_rows; // 시작 열을 구함
$to_record = $from_record + $one_rows ;
$one_sql = " select * from $g4[g4_board_file] where $one_like order by bf_datetime desc limit $from_record, $one_rows";
$one_result = sql_query($one_sql);
?>
<!----------Zzzzzzzzzzzzzzzzzzz-------->
<?
$thumb_path = $g4[path]."/data/file/thumb";
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
?>
<!-----------Zzzzzzzzzzzzzzzz--------->
<!-----------기간별 출력시작--------->
<table width=100% cellpadding=0 cellspacing=0>
<tr><td height="4"></td></tr>
<tr><td align=left><font style="font-size:12pt;"><b>이미지</b> (총 <?=$total_count?>개중 <?=$from_record+1?> -
<?
if (($from_record + ($one_rows-1)) < $total_count) {
echo "{$to_record}";
} else {
echo "{$total_count}";
}
?>)
</font>
</td></tr>
<tr><td height="10"></td></tr>
<tr><td height=1 bgcolor=#E7E7E7></td></tr>
<tr><td height="10"></td></tr>
</table>
<table width=100% cellpadding=0 cellspacing=0>
<tr>
<?//출력
for ($i=0; $one_row = sql_fetch_array($one_result); $i++){
if ($i>0 && $i%$cols==0) { echo "</tr><tr><td colspan='$cols' height='$image_h'></td></tr><tr>"; }
//<!-----------Zzzzzzzzzzzzzzzz--------->
$data_path = $g4[path]."/data/file/".$one_row[bo_table];
$thumb = $thumb_path.'/'.$one_row[bo_table]."_".$one_row[wr_id];
// 썸네일 이미지가 존재하지 않는다면
if (!file_exists($thumb))
{
$file = $data_path."/".$one_row[bf_file];
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($file))
{
$size = getimagesize($file);
if ($size[2] == 1)
$src = imagecreatefromgif($file);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($file);
else if ($size[2] == 3)
$src = imagecreatefrompng($file);
else
break;
$rate = $height_o / $size[1];
$width = (int)($size[0] * $rate);
//echo "rate : $rate ,width : $width, $height : $board[bo_2] <br>";
if($width <= $width_o) { //width가 지정된 사이즈보다 작을경우 rate 비율로 썸네일 생성
$dst = imagecreatetruecolor($width, $height_o);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $width, $height_o , $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$one_row[wr_id], $height_o );
}
else {
$rate = $width_o / $size[0];
$height = (int)($size[1] * $rate);
$dst = imagecreatetruecolor($width_o, $height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $width_o, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$one_row[bo_table]."_".$one_row[wr_id], $height_o);
}
chmod($thumb_path.'/'.$one_row[bo_table]."_".$one_row[wr_id], 0606);
}
}
if (file_exists($thumb)){
$img[$i] = "<img src='$thumb' border='0' alt='' />";
}
//<!-----------Zzzzzzzzzzzzzzzz--------->
if ($one_row[bf_width] > $one_row[bf_height]) {
$width_i1 = $width_o;
$height_i1 = ($one_row[bf_height] * $width_o) / $one_row[bf_width] ;
if ($height_i1 > $height_o) {
$width_i = ($width_i1 * $height_o) / $height_i1;
$height_i = $height_o;
} else {
$width_i = $width_i1;
$height_i = $height_i1;
}
} else if ($one_row[bf_width] < $one_row[bf_height]) {
$width_i = ($one_row[bf_width] * $height_o) / $one_row[bf_height];
$height_i = $height_o;
} else {
$width_i = $height_o;
$height_i = $height_o;
}
?>
<td valign=top align="center" width="150">
<table width="140" height="120" border="0" cellpadding="0" cellspacing="0" bgcolor='#ECECEC' onMouseOver="bgColor='#71AEFE'" onMouseOut="bgColor='#ECECEC'">
<tr><td align="center"><table bgcolor="#FFFFFF" width="136" height="116" border="0" cellpadding="0" cellspacing="0">
<tr><td align="center"><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$one_row[bo_table]?>&wr_id=<?=$one_row[wr_id]?>' onfocus='this.blur()'><?=$img[$i]?></a></td></tr>
</table></td></tr>
</table>
<table width=140 cellpadding=0 cellspacing=0><tr><td height="5"></td></tr><tr><td align="left">
<?
$sql = " select wr_subject from $g4[write_prefix]$one_row[bo_table] where wr_id = '$one_row[wr_id]' ";
$row = sql_fetch($sql);
$sql2 = " select bo_subject from $g4[board_table] where bo_table = '$one_row[bo_table]' ";
$row2 = sql_fetch($sql2);
?>
<a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$one_row[bo_table]?>&wr_id=<?=$one_row[wr_id]?>' onfocus='this.blur()'><b><u><?=cut_str($row[wr_subject], 16)?></u></a></td></tr>
<tr><td height="5"></td></tr>
<tr><td align="left"> <?=$row2[bo_subject]?></td></tr>
</table>
</td>
<? } ?>
</tr>
<tr><td width="150" height="10"></td><td width="150" height="10"></td><td width="150" height="10"></td><td width="150" height="10"></td><td width="150" height="10"></td></tr>
</table>
<table width=100% cellpadding=0 cellspacing=0>
<tr><td height=1 bgcolor=#E7E7E7></td></tr>
<tr><td height="10"></td></tr>
<tr><td>
<?
$page = get_paging($config[cf_write_pages], $page, $total_page, "?&page=");
echo "$page";
?>
</td></tr>
<tr><td height="10"></td></tr>
</table>
<?
include_once("$g4[path]/_tail.php");
?>