썸네일 최근 게시물 질문입니다. > 그누4 질문답변

그누4 질문답변

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

썸네일 최근 게시물 질문입니다. 정보

썸네일 최근 게시물 질문입니다.

첨부파일

latest.skin.php (5.3K) 4회 다운로드 2008-04-03 10:43:07

본문

$sql="select a.wr_id,a.wr_subject,b.bf_file from g4_write_$bo_table as a, g4_board_file as b where";
  $sql.=" b.bo_table='$bo_table' and (a.wr_id=b.wr_id and b.bf_no='0' and a.wr_is_comment='0') order by a.wr_id desc limit 1";
  $rs = mysql_query($sql);
  if($rs) {
  $data = mysql_fetch_array($rs);

$img_width = "95";  //썸네일 가로길이
$img_height = "60"; //썸네일 세로길이
$img_quality = "80"; //이미지 질
$img_text = "14"; //썸네일 제목 길이

if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 갤러리 게시판 입니다.");

$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumbLatest';

@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);

 $thumb = $thumb_path.'/'.$data[wr_id];
      if (!file_exists($thumb)) {
        $file = $data_path .'/'. $data[bf_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.'/'.$data[wr_id], $img_quality);
            chmod($thumb_path.'/'.$data[wr_id], 0606);
        }
    }

  if (file_exists($thumb))
        $view_img = "<a href='./$g4[bbs_path]/board.php?bo_table=$bo_table&wr_id=$data[wr_id]'><img src='$thumb' width='$img_width' height='$img_height' border='0'></a>";

위의 소스는 가장 최근에 올라온 게시물은 사진파일이 없을시,
보여주지 않고, 그 전에 올라온 사진파일이 있는 게시물만 최근게시물에 나타나는데요.

여기서 이미지가 없다는 표시인 "noimage.gif"란 파일을 올리고,
가장 최근에 작성한 파일이 이미지가 없을때 이 파일로 대체하고 나타나게 할 수 있게
수정 좀 부탁드립니다.

썸네일을 적용해서 건드리지가 쉽지 않네요.
꼭 부탁드리겠습니다.
  • 복사

댓글 전체

맨 끝에
else
$view_img = "<a href='./$g4[bbs_path]/board.php?bo_table=$bo_table&wr_id=$data[wr_id]'><img src='$latest_skin_path/img/noimage.gif' width='$img_width' height='$img_height' border='0'></a>";
$sql="select a.wr_id,a.wr_subject,b.bf_file from g4_write_$bo_table as a, g4_board_file as b where";
  $sql.=" b.bo_table='$bo_table' and (a.wr_id=b.wr_id and b.bf_no='0' and a.wr_is_comment='0') order by a.wr_id desc limit 1";

query문을 봐서는 게시물을 하나만 가져 오는데 맞나요?
$sql="select a.wr_id,a.wr_subject,b.bf_file from g4_write_$bo_table as a, g4_board_file as b where";
  $sql.=" b.bo_table='$bo_table' and (a.wr_id=b.wr_id and b.bf_no='0' and a.wr_is_comment='0') order by a.wr_id desc limit 1";
  $rs = mysql_query($sql);
  if($rs) {
  $data = mysql_fetch_array($rs);

$img_width = "95";  //썸네일 가로길이
$img_height = "60"; //썸네일 세로길이
$img_quality = "80"; //이미지 질
$img_text = "14"; //썸네일 제목 길이


===>

 $data= $list[0];
 $data['file']= get_file( $bo_table, $list[0]['wr_id']);

 $date['bf_file']= $data['file']['file'];
 
$img_width = "95";  //썸네일 가로길이
$img_height = "60"; //썸네일 세로길이
$img_quality = "80"; //이미지 질
$img_text = "14"; //썸네일 제목 길이
© SIRSOFT
현재 페이지 제일 처음으로