view.skin.php에 썸네일 적용 방법 문의 정보
view.skin.php에 썸네일 적용 방법 문의본문
list.skin.php에서 생성시킨 썸네일을
view.skin.php내에도 적용을 하려 하는데 잘 안되네요.
즉, view.skin.php에서 원본 이미지 파일 자리에 썸네일을 앉히려는 의도입니다.
검색을 해봤지만 마땅한 소스를 찾지 못해서 이렇게 도움을 구합니다.
--------------------------------------------------------------------
list.skin.php의 썸네일 소스
<?
for ($i=0; $i<count($list); $i++)
{
$img = "$board_skin_path/img/no_img.gif";
$thumb = $thumb_path.'/'.$list[$i][wr_id];
for ($i=0; $i<count($list); $i++)
{
$img = "$board_skin_path/img/no_img.gif";
$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("/\.(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;
if (!file_exists($thumb)) {
$file = $list[$i][file][0][path] .'/'. $list[$i][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);
$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]);
imagepng($dst, $thumb_path.'/'.$list[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
}
}
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]);
imagepng($dst, $thumb_path.'/'.$list[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
}
}
?>
-----------------------------------------------------------------------------
위 소스를 적용해서 썸네일을 만드는 것과 리스트에 썸네일이 나오게 하는 것에 대해서는 문제가 없었습니다.
다만 생성된 섬네일을 view.skin.php 내의
<?
// 파일 출력
for ($i=0; $i<=count($view[file]); $i++) {
if ($view[file][$i][view])
echo $view[file][$i][view] . "<p>";
}
?>
// 파일 출력
for ($i=0; $i<=count($view[file]); $i++) {
if ($view[file][$i][view])
echo $view[file][$i][view] . "<p>";
}
?>
▲ 이 자리에 적용시키는게 무척 까다롭네요.
고수님들의 조언을 구합니다.
댓글 전체
http://www.sir.co.kr/bbs/board.php?bo_table=cm_free&wr_id=147049
코멘트를 보시면 뷰페이지에서 모든 첨부파일의 썸네일 생성 및 정렬 방법등의 팁이 있습니다.
그걸 응용해보시기 바랍니다.
코멘트를 보시면 뷰페이지에서 모든 첨부파일의 썸네일 생성 및 정렬 방법등의 팁이 있습니다.
그걸 응용해보시기 바랍니다.
플록님의 방법이 아닌 순 노가다와 삽질로 겨우 알아냈습니다.
늘 그렇지만 알고보면 별 것도 아닌 것을..... ㅋㅋ
그래도 플록님께 감사하는 마음으로 답변 채택합니다. ^^
늘 그렇지만 알고보면 별 것도 아닌 것을..... ㅋㅋ
그래도 플록님께 감사하는 마음으로 답변 채택합니다. ^^