썸네일 이미지 사이즈 관련 SOS~~

썸네일 이미지 사이즈 관련 SOS~~

QA

썸네일 이미지 사이즈 관련 SOS~~

본문


 
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가 
// 제목이 두줄로 표시되는 경우 이 코드를 사용해 보세요.
// <nobr style='display:block; overflow:hidden; width:000px;'>제목</nobr>
$board[bo_1] = "200";
$board[bo_2] = "150";
$board[bo_3] = "100";
if (!$board[bo_1]) alert("게시판 설정 : 여분 필드 1 에 목록에서 보여질 이미지의 폭을 설정하십시오. (픽셀 단위)");
if (!$board[bo_2]) alert("게시판 설정 : 여분 필드 2 에 목록에서 보여질 이미지의 높이을 설정하십시오. (픽셀 단위)");
if (!$board[bo_3]) alert("게시판 설정 : 여분 필드 3 에 목록에서 보여질 이미지의 질(quality)을 비율로 설정하십시오. (100 이하)");
if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 갤러리 게시판 입니다.");
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb';
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
$mod = $board[bo_gallery_cols];
$td_width = (int)(100 / $mod);
?>
 
------------------------------------------------------------------------------------------------------
 
<?
for ($i=0; $i<count($list); $i++) 
{ 
 $homepageurl="";
 //추가
 if($list[$i][wr_1] >= 100)
  {
   $ing="[작업완료]";
   //$homepageurl=$list[wr_link1];
   if($list[$i][wr_link1]) $homepageurl="<a href='".$list[$i][wr_link1]."' target=_blank>";
  }
 else $ing="";
 $image = $list[$i][file][0][file];
 $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 계산,, 썸네일은 가로 정렬임으로 세로가 동일해야 함 */
   /*
   $rate = $board[bo_1] / $size[0];
   $height = (int)($size[1] * $rate);
   $dst = imagecreatetruecolor($board[bo_1], $height);
   imagecopyresampled($dst, $src, 0, 0, 0, 0, $board[bo_1], $height, $size[0], $size[1]);
   imagepng($dst, $thumb_path.'/'.$list[$i][wr_id], $board[bo_2]);
   chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
   */

   $rate = $board[bo_2] / $size[1];
   $width = (int)($size[0] * $rate);
     
   //echo "rate : $rate ,width : $width, $height : $board[bo_2] <br>";
   if($width <= $board[bo_1]) { //width가 지정된 사이즈보다 작을경우 rate 비율로 썸네일 생성
    $dst = imagecreatetruecolor($width, $board[bo_2]);
    imagecopyresampled($dst, $src, 0, 0, 0, 0, $width, $board[bo_2], $size[0], $size[1]);
    imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $board[bo_2]);
   } else {
    $rate = $board[bo_1] / $size[0];
    $height = (int)($size[1] * $rate);
    $dst = imagecreatetruecolor($board[bo_1], $height);
    imagecopyresampled($dst, $src, 0, 0, 0, 0, $board[bo_1], $height, $size[0], $size[1]);
    imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $board[bo_2]);
   }
     
   chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
  }
 }
  $photo_view = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];
 if (file_exists($thumb)){
  $img = "<img src='$thumb' style=display:block border=0> "; // 썸네일이미지 크기 강제 조정
 }
 
    $title = "클릭하시면 해당 사이트로 이동합니다.";
    $content = cut_str(get_text($list[$i][wr_content]), 80);
    //$img = "$g4[path]/data/file/$bo_table/".urlencode($list[$i][file][0][file]);
    //if (!file_exists($img) || !$list[$i][file][0][file])
 if ( !$list[$i][file][0][file])
        $img = "<img src=$board_skin_path/img/no_image.gif>";
    $href = "$g4[bbs_path]/board.php?bo_table=$bo_table&wr_id={$list[$i][wr_id]}&no=1";
    $view_href = "";
    //if ($is_admin) 
        $view_href = "<a href='$g4[bbs_path]/board.php?bo_table=$bo_table&wr_id={$list[$i][wr_id]}' class='highslide' onclick='return hs.expand(this)'>";
    $checkbox = "";
    if ($is_checkbox)
        $checkbox = "<input type=checkbox name=chk_wr_id[] value='{$list[$i][wr_id]}'>";
 if($list[$i][wr_2]) $btimg_dc="<img src='$board_skin_path/img/dc.gif' border=0 align=absmiddle>";
 else $btimg_dc="";
 $btimg_order="$board_skin_path/img/bt_order.gif";
 $btimg_view="$board_skin_path/img/bt_view.gif";
 $order_href="<a href='$g4[bbs_path]/write.php?bo_table=order&bunru=w&subject1={$list[$i][subject]}&code1={$list[$i][wr_1]}'>";
    $tr = ""; 
    if ($i && $i%$board[bo_gallery_cols]==0) 
        $tr = "</tr><tr>"; 
    echo "$tr"; 
    $subject = "<span $style>".cut_str($list[$i][subject],50)."</span>";
 echo "<td width='{$td_width}%' valign='top' align='center'>";
 echo "<table cellpadding='4' cellspacing='0'>";  // 썸네일이미지 좌우여백 조정
 echo "<tr valign='top'>";
 echo "<td style='border:solid 1px #dddddd; ' align='center'>";  // 썸네일이미지 테두리 라인 컬러
 echo "<table cellpadding='0' cellspacing='0' border='0'><td align='center'><a href='$g4[path]/data/file/$bo_table/$image') class='highslide' onclick='return hs.expand(this)'>{$img}</a></td></tr></table>"; // 썸네일이미지
 echo "</td></tr>";
 //echo "<tr height=1><td></td></tr>"; // 썸네일&제목간 간격조정
 echo "<tr align=center><td><a href='{$list[$i][href]}'>$subject</a></td></tr>"; // 제목
 //echo "<tr align=center><td class=small>{$list[$i][ca_name]}</a></td></tr>";  // 카테고리
 //echo "<tr align=center><td>{$list[$i][name]}</td></tr>";      // 작성자
 if ($is_checkbox) {
 echo "<tr align=center><td>$checkbox</td></tr>";
 }
 echo "<tr align=center><td height=10></td></tr>";
 echo "</table>";
 echo "</td>";
}
// 나머지 td 를 채운다.
$cnt = $i%$mod;
if ($cnt)
    for ($i=$cnt; $i<$mod; $i++)
        echo "<td> </td>\n";
if ($i == 0)
    echo "<td colspan='$board[bo_gallery_cols]' height=50 align=center>게시물이 없습니다.</td>";
?>
 
 
우선 썸네일 이미지 출력부분 관련된 태그만 일부 올렸습니다.
썸네일 이미지 가로사이즈는 200픽셀로 고정하고
세로는 원본비율에 따라 유동적으로 출력되도록 하려고 하는데요...
질문답변에서 검색을 해봤는데 제가 사용하고 있는 스킨과는 다른 스킨에 대한 답변들뿐...
응용을 한다고 해봤지만 디자이너인 제게는 능력밖의 일인지라... 잘 안되네요...
도와주세요~~ 제발~~~ㅜㅜ

이 질문에 댓글 쓰기 :

답변 2

꼼수를 써서 저 나름대로 해결한 방법을 올려봅니다 ^^;
 
소스창 줄번호 5,6,7 부분에서
가로 사이즈($board[bo_1])를 원하는 사이즈인 "200"으로 주고
세로 사이즈($board[bo_2])는 그냥 대충 가로사이즈보다 큰 수치로 넣어주니
가로값인 200에 맞춰지고 세로는 유동적으로 사이즈 조절되서 출력되네요.
세로 500픽셀보다 세로로 더 긴 비율의 이미지가 있을 경우
세로값을 다시 500 이상으로 조절해 주면 가로값에 맞춰서 조절되네요.
그냥 정~~ 해결이 안될때 참고하시라고... ^^;
허접한 정보였습니당~~
 
$board[bo_1] = "200";
$board[bo_2] = "500";
$board[bo_3] = "100";

 
답변을 작성하시기 전에 로그인 해주세요.
전체 126,146 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT