썸네일인데 옆에 공란이 들어가네요. > 그누4 질문답변

그누4 질문답변

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

썸네일인데 옆에 공란이 들어가네요. 정보

썸네일인데 옆에 공란이 들어가네요.

본문

썸네일 최근 게시물인데요...
소스에는 문제 없는 코드인거 같은데...

지금 썸네일 가로크기를 250으로 주었는데.
어느 테이블 가로를 250으로 설정하고,
그안에 최근게시물로 불러오면
이미지가 없을때는 공란없이 딱 들어맞는데,
이미지가 있을때는 세로는 딱붙는데,
가로엔 좌3px, 우3px씩 더 들어가서,
정해진 테이블을 늘려버리네요.
어디서 잘못된걸까요?
가르쳐주세요 부탁드립니다.

아래는 소스입니다.

<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가

$cols  = 1; //  이미지 가로갯수 //  이미지 세로 갯수는 메인에서 지정(총 이미지 수)
$image_h  = 0; // 이미지 상하 간격
$col_width = (int)(100 / $cols);

$img_width = 250; //썸네일 가로길이
$img_height = 188; //썸네일 세로길이
$img_quality = 99; //퀼리티 100이하로 설정

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

$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb105'; //썸네일 이미지 생성 디렉토리

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

?>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
  <?  for ($i=0; $i<count($list); $i++) {
    if ($i>0 && $i%$cols==0) { echo "<td colspan='$cols' height='$image_h'></td><tr>"; }
    $img = "<img src='$latest_skin_path/img/noimg.gif' width='$img_width' height='$img_height' title='이미지 없음'>";
    $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;

            $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]);
            imagepng($dst, $thumb_path.'/'.$list[$i][wr_id], $img_quality);
            chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
        }
    }

    if (file_exists($thumb))
        $img = "<img src='$thumb' align=left>";
?>
<?
        $datetime = substr($list[$i][wr_datetime],0,10);
        $datetime2 = $list[$i][wr_datetime];
       
        if ($list[$i]['wr_datetime'] >= date("Y-m-d H:i:s", $g4['server_time'] - ($row['bo_new'] * 3600))) $comment_new = "new";

        if ($datetime == $g4[time_ymd])
            $datetime2 = substr($datetime2,11,5);
        else
            $datetime2 = substr($datetime2,5,5);

    $list[$i][datetime] = $datetime;
    $list[$i][datetime2] = $datetime2;
   
    $a[$i] = array(
      "wr_date"=>$datetime2,
);
?>
<?
 $rw_subject = cut_str(stripslashes($list[$i][subject]),$subject_size,'..');
 $a_link="<a href='{$list[$i][href]}'>$rw_subject</a>";
 $a_img="<a href='{$list[$i][href]}'>$img</a>";
 $a_comment="<a href=\"{$list[$i][comment_href]}\"><span class='commentFont'>{$list[$i]['comment_cnt']}</span></a>";
 $rw_content = cut_str(stripslashes($list[$i][wr_content]),$content_size,' ..more');
 $rw_content = strip_tags($rw_content);
?>
    <td align=center valign="top">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td align="center"><?=$a_img?></td>
        </tr>
        <tr>
          <td height="3" align="center" bgcolor="#000000"></td>
        </tr>
        <tr>
          <td width="$img_width" align="center"><a href='<?=$list[$i][href]?>'><span style='font-size:8pt;'><font color='#6A6A6A'><?=$list[$i]['subject']?></font></span></a></td>
        </tr>
      </table>
    </td>
  <? } $cnt = ($i%$cols); for ($k=$cnt; $k<$cols && $cnt; $k++) ?>
  </tr>
</table>

<script language="javascript">
function popupImage(imageURL){
imageHandle=open("","popupForImage","toolbar=no,location=no,status=no,manubar=no,scrollbars=no,resizable=no,width=100,height=100,top=0,left=0");
  imageHandle.document.write("<title>  </title>");
  imageHandle.document.write("<style>");
  imageHandle.document.write("*{margin:0;padding:0;border:0;}");
  imageHandle.document.write("</style>");
  imageHandle.document.write("<img src=\""+imageURL+"\" onload=\"window.resizeTo(this.width+6,this.height+55);\" onclick=\"self.close();\" style=\"cursor:hand;\" title=\"클릭하면 닫힙니다.\">");
}
</script>
  • 복사

댓글 전체

위의 소스가 복잡해서 대충 봤는데요.

소스 중간쯤에

if (file_exists($thumb))
        $img = "<img src='$thumb' align=left>";


부분을

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

로 수정해보세요


그래도 잘안되면

<style type="text/css">
IMG{border:0px; margin:0px; padding:0px;}
</style>

을 파일에 추가해서 넣어보세요.
에고 죄송하네요.

제가 졸린 눈으로 대충 봤네요.

그럼 썸네일생성되는 부분을 수정하면 될거같네요.

아래처럼 해보세요..


// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면

부분 바로 위부분에 아래의 소스를 추가하세요



$delete_width = 6;  // 줄여야할 가로 사이즈
if($size[0] > $img_width ) //계산된 썸네일 넓이가 설정된 이미지보다 크다면..
    $size[0] = $size[0] - $delete_width;

// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면



오류나는 사이트 주소가 없어서 자세하게 어떤 증상인지 알수가 없어

말씀하신 상황으로만 답변을 드렸습니다.

테스트환경이 갖춰지지 않아 눈으로만 본것이라 ....

혹시 이것도 안될지도 모르겠네요..^^;;
© SIRSOFT
현재 페이지 제일 처음으로