그룹최신글 no_image.gif 출력방법? > 그누4 질문답변

그누4 질문답변

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

그룹최신글 no_image.gif 출력방법? 정보

그룹최신글 no_image.gif 출력방법?

본문

 
위에 스킨 설치는 제대로해서 잘 출력되는데요?
 
문제는 게시물에 이미지가 없을경우...
 
원래 대부분의 스킨은 no_image.gif 출력되잖아요.
 
그런데 이런 에러가 발생합니다.
 
Warning: imagejpeg(): Unable to open './skin/latest/cunic_group/img/noimage.gifThumb' for writing in /home/love/public_html/html/skin/latest/cunic_group/latest.skin.php on line 77
 
77줄은....
ImageJpeg($newim, $destfile, 100);
 
이 부분인데요. 지우니깐..에러는 없어지는데..
 
이미지가 안보이네요?
 
이미지가 없을경우 no_image.gif 출력하는 대체 방법좀 알려주세요? 
 
/////////////////////////////////////////////////////////////////
 
<?
for ($k=0; $k<count($list); $k++)
{
    if ($k > 0)
     $title =  cut_str(get_text($list[$k][wr_subject]),20);
    $content = cut_str(get_text($list[$k][wr_content]), 80);
    $img = "$g4[path]/data/file/{$list[$k][bo_table]}/".urlencode($list[$k][file][0][file]);
    if (!file_exists($img) || !$list[$k][file][0][file])
    $img = "$latest_skin_path/img/noimage.gif";
    $href = "$g4[bbs_path]/board.php?bo_table=$bo_table";
 $thumbx=100;
 $thumby=75;
 $thumbyy = $thumby+6;
    $destfile =$img.'Thumb';
   
    $size = @getimagesize($img);
    if(is_array($size) && !is_file($destfile)) {
     switch($size[2]) {
      case(1) :
       if(function_exists('ImageCreateFromGif')) $im = ImageCreateFromGif($img);
       break;
      case(2) :
       if(function_exists('ImageCreateFromJpeg')) $im = ImageCreateFromJpeg($img);
       break;
      case(3) :
       if(function_exists('ImageCreateFromPng')) $im = ImageCreateFromPng($img);
       break;
     }
     $fixsize = mando_image_size($size[0], $size[1], $thumbx, $thumby);
     if($im) {
      if($k==0) @exec("rm ".dirname($_SERVER[SCRIPT_FILENAME])."/data/file/$bo_table/*Thumb-rf");
      if(function_exists('ImageCreateTrueColor')) $newim = ImageCreateTrueColor($fixsize[x],$fixsize[y]);
      else $newim = ImageCreate($fixsize[x],$fixsize[y]);
      if(function_exists('ImageCopyResampled')) ImageCopyResampled($newim,$im,0,0,0,0,$fixsize[x],$fixsize[y],$size[0],$size[1]);
      else ImageCopyResized($newim,$im,0,0,0,0,$fixsize[x],$fixsize[y],$size[0],$size[1]);
      ImageDestroy($im);
      ImageJpeg($newim, $destfile, 100);
      ImageDestroy($newim);
      unset($im, $newim);
     }
     $list[$k][img][x] = $fixsize[x];
     $list[$k][img][y] = $fixsize[y];
    } else {
     if(is_file($destfile)) {
      $size = @getimagesize($destfile);
      $list[$k][img][x] = $size[0];
      $list[$k][img][y] = $size[1];
     } else {
      $img = "";
      $size = @getimagesize($img);
      $list[$k][img][x] = $thumbx;
      $list[$k][img][y] = $thumby;
     }
    }
    if(is_file($destfile))$img = $destfile;
 if($k==0){   
    echo <<<HEREDOC
    <td align="center" width="90">
      <table width="100" cellpadding="0" cellspacing="0" border="0" style="padding:2px;">
       <tr align=center>
        <td width="100" align="center"  style='padding-top:0px;'>
             <div align=center><table width="100" align="center"  bgcolor='#ffffff' cellpadding="3" cellspacing="0" border="0">
          <tr><td align="center" valign="middle" style='border:1px solid #cfcfcf'><a href="{$list[$k][href]}"><img src=" {$destfile}" width="{$list[$k][img][x]}" height="{$list[$k][img][y]}" border="0" alt="$content"></a></td>
          </tr>
         </table></div>
        </td>
       </tr>
       <tr>
        <td height=17 align="center" valign="middle" style='padding-top:5px;padding-bottom:5px;border:0px solid #777777'><a href="{$list[$k][href]}" style='font-family:돋움;font-size:11px;color:#336666'>{$list[$k][wr_subject]}</a></td>
       </tr>
      </table>
     </td>
  <td align="center" >
      <table width="100%" height=90 cellpadding="0" cellspacing="0" border="0" style="padding:0px;" >
HEREDOC;
 }else{
  echo <<<HEREDOC
         <tr>
        <td height=17 align="left" valign="middle" style='padding-top:2px;padding-bottom:2px;border:0px solid #777777'><img src="$latest_skin_path/img/board_icon.gif" width="4" height="7"> <a href="{$list[$k][href]}" style='font-family:돋움;font-size:12px;color:#336666'>[{$list[$k][bo_subject]}]$title</a></td>
       </tr>
HEREDOC;
   if($i<(count($list)-1)){echo "<tr><td colspan='9' height='1' background='$latest_skin_path/img/dot_line.gif'></td></tr>";}
 }
}
?>
 

댓글 전체

원래 대부분의 스킨은 no_image.gif 출력되잖아요

위에 보시면 no_image.gif 이렇게 하시길 원하시는지는 잘 모르겠는데요.
내용을 보니까 노이미부분에 밒에처럼 되어 있네요..소스 맨위에 조금 내려가시다보면요..


$img = "$latest_skin_path/img/noimage.gif"; 이부분을
$img = "$latest_skin_path/img/no_image.gif"; 이헣게 함 해보세요..

그래도 문제 있을듯 한데요..저에 한계에요..ㅠ.ㅠ
죄송합니다..
그부분이라면 제가 아까전부터 이미지명 바꿔보고 했답니다.
물론 이미지도 있나 없나 확인도 해보구요!
청산유수님이 모르시면.........ㅠㅠ
아시는분이 그누에는 없을듯..........
그럼 저처럼 해보세요..
우선 lib 폴더에 아무이름.lib.php

밑에 소스를 아무 이름.lib.php로 저장 하신후에요..

//리스트스킨에서 썸네일을 보여줄때 사용
function get_smallimg_in_list($bo_table, $file, $num, $w, $h, $error_img, $style='', $copy_rule='width', $copy_pos='1', $options=''){

  global $g4;

  $temp_origine_img = "$g4[path]/data/file/$bo_table/" . urlencode($file[$num]['file']);

  if (empty($bo_table) || empty($file[$num]) || !is_file($temp_origine_img) || $w < 10 || $h < 10) {

    $temp_small = false;
  }
  else {

    if (empty($file[$num]['image_width']) || empty($file[$num]['image_height']) || empty($file[$num]['image_type'])) {

      $temp = getimagesize($temp_origine_img);
      $temp_origine_img_w = $temp[0];
      $temp_origine_img_h = $temp[1];
      $temp_origine_img_t = $temp[2];
    }
    else {

      $temp_origine_img_w = $file[$num]['image_width'];
      $temp_origine_img_h = $file[$num]['image_height'];
      $temp_origine_img_t = $file[$num]['image_type'];
    }

    $temp_small_img_w = $w;
    $temp_small_img_h = $h;
    $temp_small_dir = "$g4[path]/data/file/$bo_table/smallimg";

    if (!is_dir($temp_small_dir)){

      mkdir($temp_small_dir) or die('썸네일을 저장할 디렉토리를 생성할수 없습니다.');
    }

    $temp_small_img = "$temp_small_dir/s_{$temp_small_img_w}_{$temp_small_img_h}_" . urlencode($file[$num][file]);

    if (is_file($temp_origine_img) && !is_file($temp_small_img)) {

      $temp_small = make_smallimg ($temp_origine_img, $temp_origine_img_w, $temp_origine_img_h, $temp_origine_img_t, $temp_small_img, $temp_small_img_w, $temp_small_img_h, $copy_rule, $copy_pos);
    }
    else if (is_file($temp_origine_img) && is_file($temp_small_img)){

      $temp_small = true;
    }
    else {

      $temp_small = false;
    }
  }

  if ($temp_small) {

    return "<img src='$temp_small_img' width='$temp_small_img_w' height='$temp_small_img_h' border=0 $style onError=\"this.src='$error_img';\">";
  }
  else {

    return "<img src='$error_img' width='$w' height='$h' border=0 $style>";
  }
}

저장 하신후 index.php나 서브head.php 맨위에
님께서 저장 하신 걸
이렇게 include_once("$g4[path]/lib/님께서저장할 파일.php");

이렇게 추가 하시고요..
보여줄 리스트 스킨에

$simg = get_smallimg_in_list($board['bo_table'], $list[$i]['file'], 0, 100, 100, '$latest_skin_path/img/no_img.gif', 'style="border:0px solid #000000;" align=center', 'width', '1');

위에 줄을 <? for ($i=0; $i<count($list); $i++) {  요기즘에 넣으세요..

요 부분에 붙여 넣으세요..

이리 하니 전 아주 잘되더라구요..
헐 참 이미지 보여줄곳에 <?=$simg?> 또는 {$simg} 이런형식으로 해야 할듯 해요..

$simg = get_smallimg_in_list($board['bo_table'], $list[$i]['file'], 0, 100, 100, '$latest_skin_path/img/no_img.gif', 'style="border:0px solid #000000;" align=center', 'width', '1');

이부분에서 100,100 은 가로 세로에요..잘 조절 하시길..^^

아 그리고 위에 소스는 어느분에 유용한 소스입니다..^^
저도 부시럭님처럼 그런 경험이 있고 또 넘 복잡하고 해서 지금은 이리 사용하고 있습니다..^^
아 헷갈려서요? 다시한번 여쭈어 볼께요.
밑에 부분을....abc.lib.php로 저장했습니다. 밑줄친 부분-----------------
그다음 그누 lib폴더에 업로드 했습니다.
그다음 index.php 맨 상단에..
<?
include_once("$g4[path]/lib/abc.lib.php");
?>
여기까지 맞죠?
그다음 latest.skin.php 안에...

$simg = get_smallimg_in_list($board['bo_table'], $list[$i]['file'], 0, 100, 100, '$latest_skin_path/img/no_img.gif', 'style="border:0px solid #000000;" align=center', 'width', '1');

위에 줄을 <? for ($i=0; $i<count($list); $i++) {
넣으시라는 말씀??????????????? 이 부분에 좀 막힘
----------------------------------------------------------------------------------
//리스트스킨에서 썸네일을 보여줄때 사용
function get_smallimg_in_list($bo_table, $file, $num, $w, $h, $error_img, $style='', $copy_rule='width', $copy_pos='1', $options=''){

  global $g4;

  $temp_origine_img = "$g4[path]/data/file/$bo_table/" . urlencode($file[$num]['file']);

  if (empty($bo_table) || empty($file[$num]) || !is_file($temp_origine_img) || $w < 10 || $h < 10) {

    $temp_small = false;
  }
  else {

    if (empty($file[$num]['image_width']) || empty($file[$num]['image_height']) || empty($file[$num]['image_type'])) {

      $temp = getimagesize($temp_origine_img);
      $temp_origine_img_w = $temp[0];
      $temp_origine_img_h = $temp[1];
      $temp_origine_img_t = $temp[2];
    }
    else {

      $temp_origine_img_w = $file[$num]['image_width'];
      $temp_origine_img_h = $file[$num]['image_height'];
      $temp_origine_img_t = $file[$num]['image_type'];
    }

    $temp_small_img_w = $w;
    $temp_small_img_h = $h;
    $temp_small_dir = "$g4[path]/data/file/$bo_table/smallimg";

    if (!is_dir($temp_small_dir)){

      mkdir($temp_small_dir) or die('썸네일을 저장할 디렉토리를 생성할수 없습니다.');
    }

    $temp_small_img = "$temp_small_dir/s_{$temp_small_img_w}_{$temp_small_img_h}_" . urlencode($file[$num][file]);

    if (is_file($temp_origine_img) && !is_file($temp_small_img)) {

      $temp_small = make_smallimg ($temp_origine_img, $temp_origine_img_w, $temp_origine_img_h, $temp_origine_img_t, $temp_small_img, $temp_small_img_w, $temp_small_img_h, $copy_rule, $copy_pos);
    }
    else if (is_file($temp_origine_img) && is_file($temp_small_img)){

      $temp_small = true;
    }
    else {

      $temp_small = false;
    }
  }

  if ($temp_small) {

    return "<img src='$temp_small_img' width='$temp_small_img_w' height='$temp_small_img_h' border=0 $style onError=\"this.src='$error_img';\">";
  }
  else {

    return "<img src='$error_img' width='$w' height='$h' border=0 $style>";
  }
}
---------------------------------------------------------------------------------
다른건 다 적용 않되요^^
헉 위에

//리스트스킨에서 썸네일을 보여줄때 사용

function get_smallimg_in_list($bo_table, $file, $num, $w, $h, $error_img, $style='', $copy_rule='width', $copy_pos='1', $options=''){ ........

이런 형식은 넣으시면 않돼요...
리스트스킨에
위에 줄을 <? for ($i=0; $i<count($list); $i++) {
넣으시라는 말씀??????????????? 이 부분에 좀 막힘
요부분에서 -------->
$simg = get_smallimg_in_list($board['bo_table'], $list[$i]['file'], 0, 100, 100, '$latest_skin_path/img/no_img.gif', 'style="border:0px solid #000000;" align=center', 'width', '1');
이것을 넣으세요^^

제가 설명이 너무 잘아서 많이 도움이 못되드렸네요..
암튼 부시럭님은 저도 초보지만 같이 해쳐나가요^^
제가 아는 한도네에도 도와드릴게요..
아..많이 배워야 하네..ㅠ.ㅠ.
그리고 계속 문제 말씀해주세요..끝가지 고쳐 드릴테니깐요..^^
아마 해결 않되신듯 하네요...
저도 좀 힘들게 문제를 풀었는데..그걸 제가 자세하게 설명을 드리기가 너무
모자라네요^^;;

암튼 서로가 같은 초보이고 서로 도와야죠..^^
무족건 답글 주세요....
전체 58 |RSS
그누4 질문답변 내용 검색

회원로그인

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