썸네일 생성 > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

썸네일 생성 정보

썸네일 생성

본문

링크를 참조하면 어떠한 코드인지 알 수 있을 것 같습니다.
 
board_file 테이블에 파일이 없을 경우 다른 이미지로 교체 하였으면 하는데~
 
어떻게 하면 될까요...?
 
 
 
<?
for ($i=0; $i<count($list); $i++)
{
$data_path = $g4['path'] . "/data/file/{$list[$i][bo_table]}";//라이브러리 파일 참조
$thumb_path = $data_path . '/thumb100';
if (!is_dir($thumb_path)) {
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
}
    $filename = $list[$i]['bf_file']; //원본파일명
    $thumb = $thumb_path.'/'.$filename; //썸네일파일명
    if (!file_exists($thumb))
    {
 $file = $data_path.'/'.$filename; //원본파일명의 경로 g4_board_file_table
        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
                continue;
            $rate = 100 / $size[0];
            $height = (int)($size[1] * $rate);
            if ($height < 75)
                $dst = imagecreatetruecolor(100, $height);
            else
                $dst = imagecreatetruecolor(100, 75);
            imagecopyresampled($dst, $src, 0, 0, 0, 0, 100, $height, $size[0], $size[1]);
            imagejpeg($dst, $thumb_path.'/'.$filename, 100);
            chmod($thumb_path.'/'.$filename, 0707);
        }
    }
    if (file_exists($thumb)) {
        $img = "<img src='$thumb' border=0>";
    }
}
?>
  • 복사

댓글 전체

아래쪽 소스에서


    if (file_exists($thumb)) {
        $img = "<img src='$thumb' border=0>";
    }




    if (file_exists($thumb)) { 
        $img = "<img src='$thumb' border=0>";
    } else {
        $img = "<img src='노이미지 주소' border=0>";
}
© SIRSOFT
현재 페이지 제일 처음으로