썸네일을 못가져오는 문제를알고싶습니다. 정보
썸네일을 못가져오는 문제를알고싶습니다.
본문
해당게시물을 썸네일을가져와야하는데 노이미지로출력됩니다. ㅜㅜ
아래는해당코드입니다. 조언부탁드려요~
<?
$g4_path = ".";
include_once("./_common.php");
include_once("./_head.php");
$sql_common = " from g4_write_story";
$sql_search = " WHERE (1)";
if ($stx) {
$sql_search .= " and ( ";
switch ($sfl) {
case "mb_point" :
$sql_search .= " ($sfl >= '$stx') ";
break;
default :
$sql_search .= " ($sfl like '%$stx%') ";
break;
}
$sql_search .= " ) ";
}
if (!$sst) {
$sst = "wr_id";
$sod = "desc";
}
$sql_order = " order by $sst $sod ";
$sql = " select count(*) as cnt
$sql_common
$sql_search
$sql_order ";
$row = sql_fetch($sql);
$total_count = $row[cnt];
$rows =5;
$total_page = ceil($total_count / $rows); // 전체 페이지 계산
if (!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함
$listall = "<a href='$_SERVER[PHP_SELF]' class=tt>처음</a>";
$sql = " select *
$sql_common
$sql_search
$sql_order
limit $from_record, $rows";
$result = sql_query($sql);
$colspan = 5;
//for ($i=0; $row=sql_fetch_array($result); $i++) {
//echo "<a href='/bbs/board.php?bo_table=story&wr_id=".$row[wr_id]."'>$row[wr_hit].$row[wr_name]." " .$row[wr_subject]."</a><br>";
//echo "<a href='/bbs/board.php? bo_table=story&wr_id=".$row[wr_id]."'>".$row[wr_hit].$row[wr_name]." " .$row[wr_subject]."</a><br>";
//}
$img_width =90;
$img_height = 51;
$img_quality = 100;
if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 갤러리 게시판 입니다.");
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path."$row[wr_id]";
$ym = date("ym", $g4[server_time]);
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
?>
<style>
.dm-subject { font:bold; font-size:18px; color:#000000; padding:5 10 5 5; }
.dm-hit { text-align:center; font:bold; font-size:14px; color:#ffffff; }
.tw {
position:absolute;
left:20px;
top:76px;
width:57px;
height:48px;
z-index:1;
}
body {
background-color: #ededed;
margin-top: 80px;
}
#apDiv1 {
position:absolute;
left:64px;
top:76px;
width:57px;
height:48px;
z-index:1;
}
</style>
<? $pagelist = get_paging($config[cf_write_pages], $page, $total_page, "?$qstr=$cp_cd1&page="); ?>
<body>
<table width="950" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#FFFFFF"><table width="571" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td bgcolor="#FFFFFF">
<table width="100" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div id="pagingNew">
<?=$pagelist?></div></td>
</tr>
</table>
</td>
</tr>
</table>
<table width="100" border="0" align="center" cellpadding="0" cellspacing="10">
<tr>
<td><div align="center">
<table width="550" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td></td>
</tr>
<? for ($i=0; $row=sql_fetch_array($result); $i++) { ?>
<tr>
<td width="10%" height="60" valign="middle"><?
//썸네일 생성
$thumfile = "";
$thumb = $thumb_path. $row[wr_id];
// 썸네일 이미지가 존재하지 않는다면
if (!file_exists($thumb)) {
$file = $row[$i][file][0][path] .'/'. $row[file][0][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 = $img_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
if ($height < $img_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $img_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$result[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$result[$i][wr_id], 0606);
}
}
if (file_exists($thumb))
$thumfile = "<img src='$thumb' width='{$img_width}' height='{$img_height}' border='0' style='border:1 #eee solid' onmouseover=this.style.filter='alpha(opacity=80)' onmouseout=this.style.filter=''></a>";
else
//이미지가 없으면
$thumfile="<img src='$latest_skin_path/img/noimg.gif' width='{$img_width}' height='{$img_height}' style='border:0 #E7E7E7 solid'></a>";
//이미지가 아니네
if(preg_match("/\.(swf|wma|asf)$/i","$file") && file_exists($file))
{ $thumfile = "<script>doc_write(flash_movie('$file', 'flash$i', '$img_width', '$img_height', 'transparent'));</script>"; }
?>
<a href="/bbs/board.php? bo_table=story&wr_id=<?=$row[wr_id]?>">
<?=$thumfile?>
</a></td>
<td style="padding:5 5 5 30;" width="80%"><div style="margin-bottom:5px;"><span class="dm-subject"> <a href="/bbs/board.php? bo_table=story&wr_id=<?=$row[wr_id]?>">
<?=$row[wr_subject]?>
</a></span> <span style="color:#FF6633; font-size:10px">
<?=$row['comment_cnt']?>
</span>
<?
echo $row['icon_file'] . " ";
echo " " . $row['icon_new'];
echo " " . $row['icon_link'];
echo " " . $row['icon_hot'];
?>
</div>
<div > <span style="color:#8f8f8f; padding:0 5 5 5;">
<?=$row[wr_name]?>
</span></div></td>
<td width="10%" align="center" valign="middle"><table width="50" border="0" cellspacing="0" cellpadding="5">
<tr>
<td height="40" background="<?=$latest_skin_path?>/img/hit_bg.gif"><div class="dm-hit">
<?=$row[wr_hit]?>
</div></td>
</tr>
</table>
<!--<a href='/bbs/board.php? bo_table=story&wr_id=".$row[wr_id]."'> --></td>
</tr>
<tr>
<td colspan="3" height="1" bgcolor="#f3f3f3"></td>
</tr>
<? } ?>
<? if (count($result) == 0) { echo "<tr><td align=center height=50><font color=#6A6A6A>오늘 등록된 게시물이 없습니다.</a></td></tr>"; } ?>
</table>
</div></td>
</tr>
</table>
<p> </p></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<table width="950" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#EDEDED"> </td>
</tr>
</table>
</body>
</html>
아래는해당코드입니다. 조언부탁드려요~
<?
$g4_path = ".";
include_once("./_common.php");
include_once("./_head.php");
$sql_common = " from g4_write_story";
$sql_search = " WHERE (1)";
if ($stx) {
$sql_search .= " and ( ";
switch ($sfl) {
case "mb_point" :
$sql_search .= " ($sfl >= '$stx') ";
break;
default :
$sql_search .= " ($sfl like '%$stx%') ";
break;
}
$sql_search .= " ) ";
}
if (!$sst) {
$sst = "wr_id";
$sod = "desc";
}
$sql_order = " order by $sst $sod ";
$sql = " select count(*) as cnt
$sql_common
$sql_search
$sql_order ";
$row = sql_fetch($sql);
$total_count = $row[cnt];
$rows =5;
$total_page = ceil($total_count / $rows); // 전체 페이지 계산
if (!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함
$listall = "<a href='$_SERVER[PHP_SELF]' class=tt>처음</a>";
$sql = " select *
$sql_common
$sql_search
$sql_order
limit $from_record, $rows";
$result = sql_query($sql);
$colspan = 5;
//for ($i=0; $row=sql_fetch_array($result); $i++) {
//echo "<a href='/bbs/board.php?bo_table=story&wr_id=".$row[wr_id]."'>$row[wr_hit].$row[wr_name]." " .$row[wr_subject]."</a><br>";
//echo "<a href='/bbs/board.php? bo_table=story&wr_id=".$row[wr_id]."'>".$row[wr_hit].$row[wr_name]." " .$row[wr_subject]."</a><br>";
//}
$img_width =90;
$img_height = 51;
$img_quality = 100;
if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 갤러리 게시판 입니다.");
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path."$row[wr_id]";
$ym = date("ym", $g4[server_time]);
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
?>
<style>
.dm-subject { font:bold; font-size:18px; color:#000000; padding:5 10 5 5; }
.dm-hit { text-align:center; font:bold; font-size:14px; color:#ffffff; }
.tw {
position:absolute;
left:20px;
top:76px;
width:57px;
height:48px;
z-index:1;
}
body {
background-color: #ededed;
margin-top: 80px;
}
#apDiv1 {
position:absolute;
left:64px;
top:76px;
width:57px;
height:48px;
z-index:1;
}
</style>
<? $pagelist = get_paging($config[cf_write_pages], $page, $total_page, "?$qstr=$cp_cd1&page="); ?>
<body>
<table width="950" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#FFFFFF"><table width="571" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td bgcolor="#FFFFFF">
<table width="100" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div id="pagingNew">
<?=$pagelist?></div></td>
</tr>
</table>
</td>
</tr>
</table>
<table width="100" border="0" align="center" cellpadding="0" cellspacing="10">
<tr>
<td><div align="center">
<table width="550" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td></td>
</tr>
<? for ($i=0; $row=sql_fetch_array($result); $i++) { ?>
<tr>
<td width="10%" height="60" valign="middle"><?
//썸네일 생성
$thumfile = "";
$thumb = $thumb_path. $row[wr_id];
// 썸네일 이미지가 존재하지 않는다면
if (!file_exists($thumb)) {
$file = $row[$i][file][0][path] .'/'. $row[file][0][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 = $img_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
if ($height < $img_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $img_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$result[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$result[$i][wr_id], 0606);
}
}
if (file_exists($thumb))
$thumfile = "<img src='$thumb' width='{$img_width}' height='{$img_height}' border='0' style='border:1 #eee solid' onmouseover=this.style.filter='alpha(opacity=80)' onmouseout=this.style.filter=''></a>";
else
//이미지가 없으면
$thumfile="<img src='$latest_skin_path/img/noimg.gif' width='{$img_width}' height='{$img_height}' style='border:0 #E7E7E7 solid'></a>";
//이미지가 아니네
if(preg_match("/\.(swf|wma|asf)$/i","$file") && file_exists($file))
{ $thumfile = "<script>doc_write(flash_movie('$file', 'flash$i', '$img_width', '$img_height', 'transparent'));</script>"; }
?>
<a href="/bbs/board.php? bo_table=story&wr_id=<?=$row[wr_id]?>">
<?=$thumfile?>
</a></td>
<td style="padding:5 5 5 30;" width="80%"><div style="margin-bottom:5px;"><span class="dm-subject"> <a href="/bbs/board.php? bo_table=story&wr_id=<?=$row[wr_id]?>">
<?=$row[wr_subject]?>
</a></span> <span style="color:#FF6633; font-size:10px">
<?=$row['comment_cnt']?>
</span>
<?
echo $row['icon_file'] . " ";
echo " " . $row['icon_new'];
echo " " . $row['icon_link'];
echo " " . $row['icon_hot'];
?>
</div>
<div > <span style="color:#8f8f8f; padding:0 5 5 5;">
<?=$row[wr_name]?>
</span></div></td>
<td width="10%" align="center" valign="middle"><table width="50" border="0" cellspacing="0" cellpadding="5">
<tr>
<td height="40" background="<?=$latest_skin_path?>/img/hit_bg.gif"><div class="dm-hit">
<?=$row[wr_hit]?>
</div></td>
</tr>
</table>
<!--<a href='/bbs/board.php? bo_table=story&wr_id=".$row[wr_id]."'> --></td>
</tr>
<tr>
<td colspan="3" height="1" bgcolor="#f3f3f3"></td>
</tr>
<? } ?>
<? if (count($result) == 0) { echo "<tr><td align=center height=50><font color=#6A6A6A>오늘 등록된 게시물이 없습니다.</a></td></tr>"; } ?>
</table>
</div></td>
</tr>
</table>
<p> </p></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<table width="950" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#EDEDED"> </td>
</tr>
</table>
</body>
</html>
댓글 전체
지디라이브러리!
죄송합니다 _ _ )
죄송합니다 _ _ )
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path."$row[wr_id]"; 이 부분에서
$thumb_path = $data_path."/".$row[wr_id]; <- 변경해 보세요 ;;; (썸네일 이시라면 /thum 같이 하셔도 될듯 합니다.
그리고 하단의
$thumb = $thumb_path. $row[wr_id]; 이부분은
$thumb = $thumb_path; 로 이미 wr_id 정보 까지 다 들어간듯 합니다.
png 가 생성이 안되는 부분은 jpg 썸네일로 대처하시면 될듯 합니다.
아침에 잠시 살펴보고 말씀 드리는 것이라 정확하지 않을 경우 다시 한번 질문란에 답변 남겨 주세요 ^^
$thumb_path = $data_path."$row[wr_id]"; 이 부분에서
$thumb_path = $data_path."/".$row[wr_id]; <- 변경해 보세요 ;;; (썸네일 이시라면 /thum 같이 하셔도 될듯 합니다.
그리고 하단의
$thumb = $thumb_path. $row[wr_id]; 이부분은
$thumb = $thumb_path; 로 이미 wr_id 정보 까지 다 들어간듯 합니다.
png 가 생성이 안되는 부분은 jpg 썸네일로 대처하시면 될듯 합니다.
아침에 잠시 살펴보고 말씀 드리는 것이라 정확하지 않을 경우 다시 한번 질문란에 답변 남겨 주세요 ^^
이런 읽어 보니 엉망으로 제가 설명드린 부분이 많네요 ^^
수정 할점 : wr_id 및 bo_table 관련 부분
게시판의 list 가 아닌 상태이니 필요한 get_file 함수 부분
이를 호출하기 위한 변수 일부 변경 및 파일명 변경 부분 등등 있네요
소스는 수정하여 쪽지로 보냈드렸습니다.
수정 할점 : wr_id 및 bo_table 관련 부분
게시판의 list 가 아닌 상태이니 필요한 get_file 함수 부분
이를 호출하기 위한 변수 일부 변경 및 파일명 변경 부분 등등 있네요
소스는 수정하여 쪽지로 보냈드렸습니다.
저도 참여해 봅니다.
82라인
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path."$row[wr_id]";
의 $thumb_path 경로와
154라인
$thumb = $thumb_path. $row[wr_id];
경로
183라인
imagejpeg($dst, $thumb_path.'/'.$result[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$result[$i][wr_id], 0606);
생성되는 경로가 틀립니다.
그래서 $thumb 로 불러오는 부분이 없기 때문에
if (file_exists($thumb)) // 섬네일 있을때
else // 없을때이기 때문에 없는 이미지가 출력 됩니다.
82라인
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path."$row[wr_id]";
의 $thumb_path 경로와
154라인
$thumb = $thumb_path. $row[wr_id];
경로
183라인
imagejpeg($dst, $thumb_path.'/'.$result[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$result[$i][wr_id], 0606);
생성되는 경로가 틀립니다.
그래서 $thumb 로 불러오는 부분이 없기 때문에
if (file_exists($thumb)) // 섬네일 있을때
else // 없을때이기 때문에 없는 이미지가 출력 됩니다.
답변해주신 zzzz님과 중년님한테 감사드려요~^^
중년님꼐서 친절하게 쪽지로 해결해주셧습니다. zzzz님도 문제점알려주신거 고맙습니다.!!
정말감사드려요~!!
중년님꼐서 친절하게 쪽지로 해결해주셧습니다. zzzz님도 문제점알려주신거 고맙습니다.!!
정말감사드려요~!!