외부이미지 사용시(썸네일이용) 최신글에 이미지 표시 할려면 어떻게 하죠? > 그누4 질문답변

그누4 질문답변

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

외부이미지 사용시(썸네일이용) 최신글에 이미지 표시 할려면 어떻게 하죠? 정보

외부이미지 사용시(썸네일이용) 최신글에 이미지 표시 할려면 어떻게 하죠?

본문

외부이미지 사용시(썸네일이용) 최신글에 이미지 표시 할려면 어떻게 하죠?
 
 
제가 위의 자료로 제가 원하는 스타일로 수정해서 쓸려니깐
 
수정을 해도해도 안됩니다. ㅜㅜ
 
부탁드립니다.
 
아주 간단하게 가로로 이미지 출력과 아래에 제목만 뜨면 되거든요..
 
아래의 소스에 썸네일 기능만을 추가해 주셨으면 합니다.
 
<?
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
?>
<!-- <?=$board[bo_subject]?> (<?=$board[bo_table]?>) 최신글 -->
<table width='100%' cellpadding='0' cellspacing='0' border='0' align='center'>
<tr><td align='center'>
<table width='95%'>
<tr>
<?
for ($i=0; $i<count($list); $i++)
{
    if ($i > 0)
        echo '<td width=20> </td>';
     $title = get_text($list[$i][wr_subject]);
    $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])
        $img = "$latest_skin_path/img/no_image.gif";
    $href = "$g4[bbs_path]/board.php?bo_table=$bo_table";
    echo <<<HEREDOC
    <td width='90' valign='top' align='center'>
        <table width='90' border='0' cellpadding='0' cellspacing='0' align='center'>
        <tr>
            <td width='90' height='80' align='center'>
  <div style='width:90px;height:80px;border:1px solid #CCCCCC;' align='center'>
  <a href='$g4[bbs_path]/board.php?bo_table=$bo_table&wr_id={$list[$i][wr_id]}'><img src='{$img}' width='90' height='80' border='0' align='absmiddle' title='$title'></a>
  </div>
     </td>
        </tr>
 <tr>
            <td width='90' align='center'><a href='$g4[bbs_path]/board.php?bo_table=$bo_table&wr_id={$list[$i][wr_id]}'>{$list[$i][subject]}</a></td>
 </tr>
 </table>
    </td>
HEREDOC;
}
?>
</tr>
<? if (count($list) == 0) { ?>
<tr><td colspan=2 align='center' height=25>게시물이 없습니다.</td></tr>
<? } ?>
</table>
</td></tr>
</table>
 
이미지 출력은 가로 90 세로 80으로 똑같이 출력 되었으면 합니다.
 
꼭좀 부탁드립니다.
  • 복사

댓글 전체

썸네일 생성 규칙이 비율을 유지하면서 가로세로가운데 큰쪽을 정해진 사이즈로 제한하는 방식입니다.
그러므로 원하시는 가로90 세로80으로 정확하게 잘라지지 않습니다.
꼭 위처럼 정해진 사이즈로 잘라야 한다면 유창화님께서 만들어 공개하신 crop방식 썸네일 생성 엔진을 사용하시면 되겠습니다.
아래 유창화님 Ythumb.lib.php 익히신후 적용하시기 바랍니다.
http://sir.co.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=10075


---------------------------------
latest.skin.php 자잘한 버그는 DIY~!!
---------------------------------
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가

//링크 썸네일 게시판을 위한 최신글 단순 썸네일 갤러리 형태 - 2007년 4월 28일 토요일 - 플록
if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 갤러리 게시판 입니다.");

# Ylink_thumb.lib.php, Yfunction.php 등 두개의 파일을 latest_skin_path 에 업로드합니다.
//외부 이미지 썸네일 생성관련 펑션이 없다면 관련파일 인크루드 - 중복사용을 위해
if (!function_exists("Ymake_sumnail_remoteimage")) {
  include_once($latest_skin_path . "/Ylink_thumb.lib.php");//본문 링크 이미지 썸네일 생성
}

# 썸네일 생성을 위해 여분필드에 정해진 값을 자동으로 넣어줍니다.
# 사용하려는 게시판의 여분필드 사용내역을 확인후 사용하지 않는 여분필드로 바꿔주셔도 됩니다.
//여분필드 기본값 설정 - 리자언니 free_img3 스킨에서
if (empty($board['bo_1'])) {
  $board['bo_1'] = "100,100";
  $sql = " update ".$g4['board_table']." set bo_1 = '".$board['bo_1']."' where bo_table = '".$bo_table."' ";
  sql_query($sql);
}
if (empty($board['bo_2'])) {
  $board['bo_2'] = "100";
  $sql = " update ".$g4['board_table']." set bo_2 = '".$board['bo_2']."' where bo_table = '".$bo_table."' ";
  sql_query($sql);
}
if (empty($board['bo_3'])) {
  $board['bo_3'] = "280";
  $sql = " update ".$g4['board_table']." set bo_3 = '".$board['bo_3']."' where bo_table = '".$bo_table."' ";
  sql_query($sql);
}

# 썸네일 가로, 세로 크기
list($w, $h) = explode(",", $board['bo_1']);

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

if (!is_dir($thumb_path)) {
  @mkdir($thumb_path, 0707);
  @chmod($thumb_path, 0707);
}

//------------------------------
//$cols = $board[bo_gallery_cols];//줄바꿈 갯수 설정
$cols = 4;
$td_width = (int)(100 / $cols);
?>

<table width=100% cellpadding=0 cellspacing=0 border=0 style="background:#eeeeee;border-top:1 solid #dddddd;">
<tr height="25">
<td style="font:bold 9pt tahoma; padding-left:10">
<a href="<?=$g4['bbs_path']?>/board.php?bo_table=<?=$bo_table?>"><?=$board['bo_subject']?></a></td>
<td align="right" style="padding-right:10">
<a href="<?=$g4['bbs_path']?>/board.php?bo_table=<?=$bo_table?>"><img src="<?=$latest_skin_path?>/img/icon_more.gif"></a></td>
</tr>
</table>

<table width=100% border="0" cellpadding=0 cellspacing=0 style="background:#CCC; border-color:black; border-collapse: collapse;" >
<tr>

<?
for ($i=0; $i<count($list); $i++){

  if ($i>0 && $i%$cols==0) {
    echo "</tr><tr>";
  }

  //------------------------------
  //본문에 링크한 이미지 레코드별 배열 - 한페이지에서 중복사용가능
  $re = '/src[ =]+[\'"]([^\'"]+\.(?:gif|jpg|png|bmp))[\'"]/i';
  preg_match_all($re, $list[$i]['wr_content'], $match, PREG_PATTERN_ORDER);
  //$imgs[$i] = $match[1][0]; //$url = $match[1][0];

  $dest_link[] = array( 'wr_id' => $list[$i]['wr_id'], 'url' => $match[1]);
  //print_r2($dest_link[$i]);
  $url = $dest_link[$i]['url']['0'];//첫번째 링크된 이미지, 두번째는 $dest_link[$i]['url'][1]
  //------------------------------
  $save_dir = $thumb_path;//임시 저장경로
  $referer = "";//속일 리퍼러, 넣지 않아도 됨

  $thumb = $save_dir . '/s_' . base64_encode($url);
  //썸네일이 없다면 본문 첫번째 링크된 이미지 파일의 썸네일을 생성합니다.
  if (!file_exists($thumb)) {
    //if ((is_file($url)) && (!file_exists($thumb))) {//원본이미지 있고 썸네일 없을때
    //유효하지 않는 링크에 대한 에러를 표시하지 않는다.
    $result = @Ymake_sumnail_remoteimage($url, $save_dir, $w, $h, $referer);
  }

  //링크에서 파일명 가져옴
  $filename = strrchr($url,"/");
  $filename = substr($filename, 1);
  $filename = urlencode($filename); //타이틀

  //------------------------------
  //첨부파일1번이 있다면 우선사용합니다.
  if ($list[$i]['file'][0]['file']){
    $filename = $list[$i]['file'][0]['file'];  //첫번째 이미지 파일로 지정
    $dest_file = $data_path .'/'. $filename;//원본 이미지

    if (preg_match("/\.(jp[e]?g|gif|png)$/i", $filename) && file_exists($dest_file)){

      $thumb = $thumb_path.'/' . $filename;

      if (!file_exists($thumb)){

        $size = getimagesize($dest_file);
        if ($size[2] == 1)
          $src = imagecreatefromgif($dest_file);
        else if ($size[2] == 2)
          $src = imagecreatefromjpeg($dest_file);
        else if ($size[2] == 3)
          $src = imagecreatefrompng($dest_file);
        else
          break;
        if ($size[0] >= $size[1]){
          $rate = $w / $size[0];
          $width = $w;
          $height = (int)($size[1] * $rate);
        }
        else{
          $rate = $h / $size[1];
          $width = (int)($size[0] * $rate);
          $height = $h;
        }
        $dst = imagecreatetruecolor($width, $height);
        imagecopyresampled($dst, $src, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
        imagejpeg($dst, $thumb, $board['bo_2']);
        chmod($thumb, 0707);

      }
    }
  }

  //----------------------------------------------------------------
  $f_title = $list[$i]['file'][0]['file']?" ".$list[$i]['file'][0]['source']."":"".$filename."";

  if (file_exists($thumb)){
    $img = "<img src='".$thumb. "' style='border: 1px solid silver;' title='".$f_title." Hit: ".$list[$i]['wr_hit']."'>";
  }
  //----------------------------------------------------------------

  $subject = ($list[$i]['is_notice'])?"<a href='".$list[$i]['href']."' style='color:#2C8CB9;font-weight:bold;'>".$list[$i]['wr_subject']."</a>":"<a href='".$list[$i]['href']."' style='font-weight:bold;'>".$list[$i]['wr_subject']."</a>";
   
  if ((!empty($list[$i][file][0][file])) || (!empty($url))) {//첨부파일1,본문링크1 있다면
 
    ?><td width='<?=$td_width?>%' align='center' valign='top' style='padding:20px 0 10px 0; border: 1px solid silver; word-break:break-all;'>
    <a href="<?=$list[$i]['href']?>"><?=$img?></a>
    <?=$subject?>
    </td><?

  }//if
}//for

//------------------------------
// 나머지 td
$cnt = $i%$cols;
if ($cnt)
  for ($k=$cnt; $k<$cols && $cnt; $k++) {
    ?><td width='<?=$td_width?>%' style='padding:20 0 5 0; border: 1px solid silver;'></td><?
  }
//------------------------------
?>
</tr>
</table>
$subject = ($list[$i]['is_notice'])?"<a href='".$list[$i]['href']."' style='color:#2C8CB9;font-weight:bold;'>".$list[$i]['wr_subject']."</a>":"<a href='".$list[$i]['href']."' style='font-weight:bold;'>".$list[$i]['wr_subject']."</a>";

-->>

  $subject = cut_str(strip_tags($list[$i]['wr_subject']), 10);
  $subject = ($list[$i]['is_notice'])?"<a href='".$list[$i]['href']."' style='color:#2C8CB9;font-weight:bold;'>".$subject."</a>":"<a href='".$list[$i]['href']."' style='font-weight:bold;'>".$subject."</a>";
안녕하세요 플록님

현재 님이 수정해 주신 스킨 잘 사용하고 있습니다
외부이미지 사용시(썸네일이용) 최신게시물 출력 스킨이요..
http://sir.co.kr/bbs/board.php?bo_table=g4_qa&wr_id=59660&sca=&sfl=wr_name%2C1&stx=%BC%F6%B6%AF%C0%CC&sop=and

근데요 <img src="">이태그를 읽어서 출력 되는거잖아요.
그런데 이미지 태그에 <img src="" alt="실제크기로 보기">
이렇게 알트 옵션이 들어가면 사이트에 부하가 생기면서 출력이 안되더라고요

그래서 계정에서 쫒겨 날 뻔 했습니다.
이 문제를 해결해 주실수 있는지요?
스킨 너무 좋은데 방문자들이 알트옵션 써서 글 작성을 하면 사이트에 부하가 생겨서요
아시면 답변 부탁드립니다.
좋은 하루되세요..
© SIRSOFT
현재 페이지 제일 처음으로