write_update.skin.php 에서...[썸네일 문의] 정보
write_update.skin.php 에서...[썸네일 문의]
본문
문의사항1.
현상 1. 첨부파일이 이미지일경우 썸네일 생성 잘됨
현상 2. 첨부파일을 교체할경우 썸네일 변경 잘됨.
현상 3. 첨부파일을 모두 삭제할 경우 최종 썸네일이 유지됨 <- 삭제되어 no img 가 표시되길 원함니다.
문의사항2.
플래시 업로더를 이용할경우 최초 썸네일만 생성되고 첨부파일 수정시 썸네일 변경이 되질 않습니다.
따라서 일반 첨부파일 업로드를 이용하고 있습니다.
write_update.skin.php 내용
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
// 여분필드(wr_tags필드를 테이블에서 추가하세요)
// 태그추가
// $sql = " update $write_table set wr_tags = '$wr_tags' where wr_id = '$wr_tags' ";
// sql_query($sql);
// 이모티콘업데이트
// $sql = " update $write_table set wr_emot = '$wr_emot' where wr_id = '$wr_emot' ";
// sql_query($sql);
//print_r2($_FILES); exit;
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb';
if ($_FILES[bf_file][name][0])
{
$row = sql_fetch(" select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' and bf_no = '0' ");
$file = $data_path .'/'. $row[bf_file];
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $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 = $thumb_width / $size[0];
$height = (int)($size[1] * $rate);
@unlink($thumb_path.'/'.$wr_id);
// 계산된 높이가 설정된 높이보다 작다면
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.'/'.$wr_id, $thumb_quality);
chmod($thumb_path.'/'.$wr_id, 0606);
}
}
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumbphoto';
if ($_FILES[bf_file][name][0])
{
$row = sql_fetch(" select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' and bf_no = '0' ");
$file = $data_path .'/'. $row[bf_file];
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $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 = $thumb_width / $size[0];
$height = (int)($size[1] * $rate);
@unlink($thumb_path.'/'.$wr_id);
// 계산된 높이가 설정된 높이보다 작다면
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.'/'.$wr_id, $thumb_quality);
chmod($thumb_path.'/'.$wr_id, 0606);
}
}
?>
댓글 전체
---------------------------------------
현상 3. 첨부파일을 모두 삭제할 경우 최종 썸네일이 유지됨 <- 삭제되어 no img 가 표시되길 원함니다.
-=> 썸네일 갱신은 되지만 삭제가 안되는 경우 입니다. 아래 2개파일 손보세요. 방법은 링크답변 참조
/bbs/delete.php // 삭제관련 <= 이파일
/bbs/delete_all.php // 삭제관련 <= 이파일
/bbs/write_update.php // 갱신관련
아래답변을 참조
http://www.sir.co.kr/bbs/board.php?bo_table=g4_qa&wr_id=130554
문의사항2.
---------------------------------------
플래시 업로더를 이용할경우 최초 썸네일만 생성되고 첨부파일 수정시 썸네일 변경이 되질 않습니다.
따라서 일반 첨부파일 업로드를 이용하고 있습니다.
---------------------------------------
그구기본 첨부파일외 에디터를 이용해서 업로드할 경우 원본디랙토리 경로가 에디터에 따라 틀려집니다.
최초 썸은 생성되지만 삭제하지않는 이상 갱신은 안됩니다. 위의 파일들과 연관이 있습니다.
wr_id를 물고 들어가 최초등록된 걸로 계속나오게 되죠
해결방법은 링크에 다 나옵니다.
