최신글 리스트 스킨 이미지 없을 때 대체 이미지 출력 방법이요. > 그누4 질문답변

그누4 질문답변

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

최신글 리스트 스킨 이미지 없을 때 대체 이미지 출력 방법이요. 정보

최신글 리스트 스킨 이미지 없을 때 대체 이미지 출력 방법이요.

본문

이리저리 하다가, 비슷하게는 간 것 같은데...


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

$list = array();

$tmp = "";
$sql= " select bo_table from {$g4['board_table']} where gr_id='$gr_id' and bo_use_search='1' ";
$result = sql_query($sql);
for($i=0; $i<$board=sql_fetch_array($result); $i++){
$tmp_write_table = $g4['write_prefix'] . $board['bo_table'];
$tmp .= " select '{$board['bo_table']}' as bo_table, wr_id, wr_subject, wr_content, wr_good, wr_hit, wr_last from $tmp_write_table where wr_is_comment=0 and date_format(wr_datetime, '%Y%m%d') between '$startYmd' and '$nowYmd' UNION ALL ";
}
if($tmp) $tmp = "select * from ( ".substr($tmp,0,-10).") as a order by wr_good desc, wr_hit desc limit 4";
$result = sql_query($tmp); 
for ($i=0; $row=sql_fetch_array($result); $i++){
$sql = "select * from {$g4['board_table']} where bo_table='$row[bo_table]'";
$board = sql_fetch($sql);

$list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
$list[$i]['bo_table'] = $board['bo_table'];
}


?>

<table width="360" height="135" border="1" bordercolor="#e1e1e1" cellpadding="0" cellspacing="0" style="BORDER-COLLAPSE: collapse" align=center>
<tr>
    <td valign=center>
        <table width="340" border="0" cellpadding="0" cellspacing="0" align=center>
        <tr>
            <td>
                <script type="text/javascript">
                var COUNT = new Array();
                function layer(id, no)
                {
                for(var i = 0; i < COUNT[id]; i++) document.getElementById(id + "_" + i).style.display = "none";
                document.getElementById(id + "_" + no).style.display = "block";
                return;
                }
                </script><script type="text/javascript">COUNT["recipe_my"] = 4;</script>
                <table border=0 cellpadding="0" cellspacing="0" width="100%" height="120">
                <tr><td height="6" colspan="2"></td></tr>
                <tr>
                    <td colspan="2">
                        <table cellpadding="0" cellspacing="0" width="100%" >
                        <tr>
                            <td valign="top">
<? for ($i=0; $i<count($list); $i++) { ?>
                                <div id="recipe_my_<?=$i?>" style="display:<?if($i==0) echo "block;";else echo "none;";?>">
                                    <table border='0' cellpadding='0' cellspacing='0'>
                                    <tr>
                                        <td align='center'>
                                            <table width=100% cellpadding="0" cellspacing="0" bordercolor="#222222" border="1" style="BORDER-COLLAPSE: collapse">
                                            <tr>
                                            <td><?
                                           
$image = $list[$i][file][0][file]; //원본
$noimg = $latest_skin_path."/img/noimg.gif"; ///////////// 여기 노이미지
$img=$data_path. "/".$image;  //썸네일이 없을경우 원본출력
$thumb = $thumb_path. "/". $list[$i][wr_id];
$thumb_path = $data_path."/thumbnail";
$data_path = $g4[path]."/data/file/$bo_table";
$file=$data_path .'/'. $row[bf_file];



  if ( file_exists($thumb) ) {//썸네일이 있다면
$img = $thumb;
} else if($image) {//원본이미지가 있다면
$img = $image;
} else {
$img = $noimg;
} //가난해서 썸네일도 없고 원본이미지도 없으면 노이미지 출력 ?>
                                            <a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$list[$i][bo_table]?>&wr_id=<?=$list[$i][wr_id]?>'>
                                            <img src="<?=$img?>" width='102' height='78' border='0'  /></a></td>
                                            </tr>
                                            </table>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td height=7 bgcolor='#FFFFFF' align=center></td>
                                    </tr>
                                    <tr>
                                        <td height=24 bgcolor='#323232' align=center><font color='#FFFFFF'><b><?=cut_str($list[$i][wr_subject],21,"...")?></b></font></td>
                                    </tr>
                                    </table>
                                </div>
<?}?>
                            </td>
                            <td width="100%" style="padding-left:10;">
                                <table cellpadding="0" cellspacing="0" width="100%">
                                <tr><td height='20'><b><font color='#56B3D2'>[그시절] 베스트글</font></b></td></tr>
                                <tr><td height='1' bgcolor='#EBEBEB'></td></tr>
                                <tr><td height='3'></td></tr>
<? for ($i=0; $i<count($list); $i++) { ?>
                                <tr><td height="22"><img src="<?=$latest_skin_path?>/images/i_bullet.gif" align="absmiddle"> <a href="./bbs/board.php?bo_table=<?=$list[$i][bo_table]?>&wr_id=<?=$list[$i][wr_id]?>" style='font-size:12px; color:#555555; vertical-align:1px;'><span OnMouseOver="this.style.fontWeight='bold'"  OnMouseOut="this.style.fontWeight=''"><?=$list[$i][subject]?></span></a>&nbsp;&nbsp;<span style='font-size:8pt;font-family:tahoma;color:#56B3D2;vertical-align:1px;'><img src="<?=$latest_skin_path?>/images/icon_re.gif"> <?=$list[$i][wr_good]?></span>&nbsp;&nbsp;<span style='font-size:8pt;font-family:tahoma;color:#fda83a;vertical-align:1px;'><img src="<?=$latest_skin_path?>/images/icon_hit.gif"> <?=$list[$i][wr_hit]?></span></td></tr>
<?}?>
                                </table>
                            </td>
                        </tr>
                       
                        </table>
                    </td>
                </tr>
                </table>

            </td>
        </tr>
        </table>
    </td>
</tr>
</table>



위에서

  <img src="<?=$img?>" width='102' height='78' border='0'  /></a></td>

위 <?=$img?> 부분을 <?=$noimg?> 부분으로 하면 대체이미지는 출력되는데

그냥 그대로 하면 엑박이 나오네요. $img 나 $image 경로가 잘못된 걸까요.

가르쳐주시면 고맙겠습니다;;;;
  • 복사

댓글 전체

위에서 // $img = $image;  부분 을 주석처리해 주시면 됩니다


$image = $list[$i][file][0][file]; //원본
$noimg = $latest_skin_path."/img/noimg.gif"; ///////////// 여기 노이미지
$img=$data_path. "/".$image;  //썸네일이 없을경우 원본출력
$thumb = $thumb_path. "/". $list[$i][wr_id];
$thumb_path = $data_path."/thumbnail";
$data_path = $g4[path]."/data/file/$bo_table";
$file=$data_path .'/'. $row[bf_file];

  if ( file_exists($thumb) ) {//썸네일이 있다면
$img = $thumb;
} else if($image) {//원본이미지가 있다면
// $img = $image;  여기 부분 주석처리해 주시면 됩니다
} else {
$img = $noimg;
} //가난해서 썸네일도 없고 원본이미지도 없으면 노이미지 출력 ?>
다음을 아래와 같이 수정해 보세요.
===================== 원본 ==========================
$image = $list[$i][file][0][file]; //원본
$noimg = $latest_skin_path."/img/noimg.gif"; ///////////// 여기 노이미지
$img=$data_path. "/".$image;  //썸네일이 없을경우 원본출력
$thumb = $thumb_path. "/". $list[$i][wr_id];
$thumb_path = $data_path."/thumbnail";
$data_path = $g4[path]."/data/file/$bo_table";
$file=$data_path .'/'. $row[bf_file];
=====================================================

==================== 수정본 ==========================
$image = $list[$i][file][0][file]; //원본
$noimg = $latest_skin_path."/img/noimg.gif"; ///////////// 여기 노이미지
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path."/thumbnail";
$img=$data_path. "/".$image;  //썸네일이 없을경우 원본출력
$thumb = $thumb_path. "/". $list[$i][wr_id];
$file=$data_path .'/'. $row[bf_file];
고맙습니다만, 두분 말씀대로 해봤는데 안되네요;;

  <?
                                           
$image = $list[$i][file][0][file]; //원본
$noimg = $latest_skin_path."/img/noimg.gif"; ///////////// 여기 노이미지
$noimg2 = $latest_skin_path."/img/icon_file.gif"; ///////////// 여기 노이미지
$noimg3 = $latest_skin_path."/img/icon_hot.gif"; ///////////// 여기 노이미지
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumbnail';
$img=$data_path. "/".$image;  //썸네일이 없을경우 원본출력
$thumb = $thumb_path. "/". $list[$i][wr_id];
$file=$data_path .'/'. $row[bf_file];

  if ( file_exists($thumb) ) {//썸네일이 있다면
$img = $noimg;
} else if($image){ //원본이미지가 있다면
$img = $noimg2;
} else {
$img = $noimg3;
} //가난해서 썸네일도 없고 원본이미지도 없으면 노이미지 출력 ?>
                                            <img src="<?=$img?>" width='102' height='78' border='0'  />


이렇게 할경우 $noimg2 가 출력되구요.


다음에

 <?
                                           
$image = $list[$i][file][0][file]; //원본
$noimg = $latest_skin_path."/img/noimg.gif"; ///////////// 여기 노이미지
$noimg2 = $latest_skin_path."/img/icon_file.gif"; ///////////// 여기 노이미지
$noimg3 = $latest_skin_path."/img/icon_hot.gif"; ///////////// 여기 노이미지
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumbnail';
$img=$data_path. "/".$image;  //썸네일이 없을경우 원본출력
$thumb = $thumb_path. "/". $list[$i][wr_id];
$file=$data_path .'/'. $row[bf_file];

  if ( file_exists($image) ) {//썸네일이 있다면
$img = $noimg;
} else {
$img = $noimg3;
} //가난해서 썸네일도 없고 원본이미지도 없으면 노이미지 출력 ?>
                                            <img src="<?=$img?>" width='102' height='78' border='0'  />

이렇게  밑에 썸네일이 있다면 줄에서 $thumb 를 $image로 바꾸고 밑에 한줄 삭제하니

$noimg3이 출력되더라구요. 뭐가 잘못된 것일까요..
© SIRSOFT
현재 페이지 제일 처음으로