최근게시물 썸네일부분 ㅠ ㅠ 정보
최근게시물 썸네일부분 ㅠ ㅠ본문
다음과 같이 썸네일 부분이 되어 있는데
처음에 파일을 올렷을때는 이미지 파일을 첨부햇을때는 썸네일이 제대로 나오는데
올린 파일을 수정 이미지를 바꿨을때
썸네일부분이 바꾼 이미지로 안바뀌는데..
그부분을 어떻게 할수 없나요?ㅠㅠ
//썸네일 생성
$thumfile = "";
$thumb = $thumb_path.'/'.$list[$i][wr_id];
// 썸네일 이미지가 존재하지 않는다면
if (!file_exists($thumb)) {
$file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];
// 업로드된 파일이 이미지라면
if (preg_match("/\.(jpg|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
continue;
$rate = $thumb_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
if ($height < $thumb_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($thumb_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($thumb_width, $thumb_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $thumb_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $thumb_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
} else { //게디터에서 삽입한 이미지 뽑자ㅠㅠ
$edit_img = $list[$i]['wr_content'];
if (eregi("data/cheditor[^<>]*\.(gif|jp[e]?g|png|bmp)", $edit_img, $tmp)) { // data/cheditor------
$file = '../' . $tmp[0]; // 파일명
$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
continue;
$rate = $thumb_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
if ($height < $thumb_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($thumb_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($thumb_width, $thumb_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $thumb_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $thumb_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
}
}
}
//이미지
if (file_exists($thumb))
$thumfile = "<img src='{$thumb}' border='0'>";
else
//이미지가 없으면
$thumfile="";
//이미지가 아니네
if(preg_match("/\.(swf|wma|asf)$/i","$file") && file_exists($file)){
$thumfile = "<script>doc_write(flash_movie('$file', 'flash$i', '$thumb_width', '$thumb_height', 'transparent'));</script>";
}
?>
<tr height=55 align=center>
<? if ($is_checkbox) { ?><td width=40><input type=checkbox name=chk_wr_id[] value="<?=$list[$i][wr_id]?>"></td><? } ?>
<td align=center width="80">
<?
if ($list[$i][wr_3] == "매매") { // 매매
echo "<img src=\"{$board_skin_path}/img/icon_01.gif\" width='38' height='16' align='absmiddle' border=0>";
}
else if ($list[$i][wr_3] == "전세") { // 전세
echo "<img src=\"{$board_skin_path}/img/icon_02.gif\" width='38' height='16' align='absmiddle' border=0>";
}
else if ($list[$i][wr_3] == "월세") { // 월세
echo "<img src=\"{$board_skin_path}/img/icon_18.gif\" width='38' height='16' align='absmiddle' border=0>";
}
?></td>
<td><table cellpadding="1" cellspacing="0" width="100%">
<tr valign="bottom">
<? if ($thumfile) {// 썸네일 ?>
<td width=50 class="gray8s" style="padding:8px 15px 8px 5px;" rowspan="2"><div style="border:1px solid #dddddd;"><a href='<?=$list[$i][href]?>'><?=$thumfile?></a></div></td>
<? }?>
처음에 파일을 올렷을때는 이미지 파일을 첨부햇을때는 썸네일이 제대로 나오는데
올린 파일을 수정 이미지를 바꿨을때
썸네일부분이 바꾼 이미지로 안바뀌는데..
그부분을 어떻게 할수 없나요?ㅠㅠ
//썸네일 생성
$thumfile = "";
$thumb = $thumb_path.'/'.$list[$i][wr_id];
// 썸네일 이미지가 존재하지 않는다면
if (!file_exists($thumb)) {
$file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];
// 업로드된 파일이 이미지라면
if (preg_match("/\.(jpg|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
continue;
$rate = $thumb_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
if ($height < $thumb_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($thumb_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($thumb_width, $thumb_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $thumb_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $thumb_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
} else { //게디터에서 삽입한 이미지 뽑자ㅠㅠ
$edit_img = $list[$i]['wr_content'];
if (eregi("data/cheditor[^<>]*\.(gif|jp[e]?g|png|bmp)", $edit_img, $tmp)) { // data/cheditor------
$file = '../' . $tmp[0]; // 파일명
$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
continue;
$rate = $thumb_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
if ($height < $thumb_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($thumb_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($thumb_width, $thumb_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $thumb_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $thumb_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
}
}
}
//이미지
if (file_exists($thumb))
$thumfile = "<img src='{$thumb}' border='0'>";
else
//이미지가 없으면
$thumfile="";
//이미지가 아니네
if(preg_match("/\.(swf|wma|asf)$/i","$file") && file_exists($file)){
$thumfile = "<script>doc_write(flash_movie('$file', 'flash$i', '$thumb_width', '$thumb_height', 'transparent'));</script>";
}
?>
<tr height=55 align=center>
<? if ($is_checkbox) { ?><td width=40><input type=checkbox name=chk_wr_id[] value="<?=$list[$i][wr_id]?>"></td><? } ?>
<td align=center width="80">
<?
if ($list[$i][wr_3] == "매매") { // 매매
echo "<img src=\"{$board_skin_path}/img/icon_01.gif\" width='38' height='16' align='absmiddle' border=0>";
}
else if ($list[$i][wr_3] == "전세") { // 전세
echo "<img src=\"{$board_skin_path}/img/icon_02.gif\" width='38' height='16' align='absmiddle' border=0>";
}
else if ($list[$i][wr_3] == "월세") { // 월세
echo "<img src=\"{$board_skin_path}/img/icon_18.gif\" width='38' height='16' align='absmiddle' border=0>";
}
?></td>
<td><table cellpadding="1" cellspacing="0" width="100%">
<tr valign="bottom">
<? if ($thumfile) {// 썸네일 ?>
<td width=50 class="gray8s" style="padding:8px 15px 8px 5px;" rowspan="2"><div style="border:1px solid #dddddd;"><a href='<?=$list[$i][href]?>'><?=$thumfile?></a></div></td>
<? }?>
댓글 전체
이미지를 다시 등록거나 게시물을 삭제하면 썸네일을 삭제하는 코드를 만들어야 합니다
그게 어려우면 소스 첫 부분
$thumb = $thumb_path.'/'.$list[$i][wr_id]; <--- 수정
$thumb = $thumb_path.'/'.$list[$i][file][0][file];
이렇게 하면 되긴하는데 게시물 삭제나 이미지 변경시에 이전 썸네일이 쓰레기로 남게 됩니다(예전 소스도 마찬가지)
그게 어려우면 소스 첫 부분
$thumb = $thumb_path.'/'.$list[$i][wr_id]; <--- 수정
$thumb = $thumb_path.'/'.$list[$i][file][0][file];
이렇게 하면 되긴하는데 게시물 삭제나 이미지 변경시에 이전 썸네일이 쓰레기로 남게 됩니다(예전 소스도 마찬가지)