썸네일 게시판인데 이미지 없을시 노이미지파일 뜨게 하고 싶어요.
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
$cols = 1; // 이미지 가로갯수 // 이미지 세로 갯수는 메인에서 지정(총 이미지 수)
$image_h = 1; // 이미지 상하 간격
$col_width = (int)(99 / $cols);
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb';
?>
<style type="text/css">
<!--
.data { font-family:돋움; font-size:8pt; color:#999999; }
-->
</style>
<table width="95" border="0" cellspacing="0" cellpadding="0">
<!-- 최신글 제목 -->
<tr>
<td align='center' width="95">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<? for ($i=0; $i<count($list); $i++) {
if ($i>0 && $i%$cols==0) { echo "</tr><tr><td colspan='$cols' height='$image_h'></td></tr><tr>"; }
?>
<td width="100%" align="center" valign='top' height="15">
<?
$image = $list[$i][file][0][file]; //원본
$img=$data_path. "/".$image; //썸네일이 없을경우 원본출력
$thumb = $thumb_path. "/". $list[$i][file][0][file];
if ( file_exists($thumb))
$img = $thumb;
$style = "font-family:돋움; font-size:8pt; color:#636363;";
if ($list[$i][icon_new])
$style = "style='font-family:돋움; font-size:8pt; color:#424542;' ";
$subject = "<span $style>".cut_str($list[$i][subject],30)."</span>"; //제목 글자수 자르기
$bg = ""; //새글?
if ($list[$i][icon_new])
$bg="la_top_2.gif";
else
$bg="la_top_1.gif";
echo $list[$i][icon_reply] . " ";
echo "<table width='75' cellpadding='0' cellspacing='0' border='0'>";
echo "<tr><td valign='top' align='center'><a href='{$list[$i]['href']}' onFocus=\"this.blur();\" title=\"{$list[$i][subject]}\"><img src='$img' width='95' height='60' border='0'></a></td></tr>";
echo "<tr><td height='21' align='center'><a href='{$list[$i]['href']}'><b><span style='font-size:10pt;'><font color='#424542'>{$subject}</font></span></b></a></td></tr></table>";
?>
</td>
<? } ?>
<?
$cnt = ($i%$cols);
for ($k=$cnt; $k<$cols && $cnt; $k++) {
echo "<td width=$col_width%> </td>";
}
?>
<? if (count($list) == 0) { echo "<td height=80 align=center>게시물이 없습니다.</td>"; } ?>
</tr>
</table></td>
</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>
원문이구요.
첨부된 이미지 파일이 없을때 noimg.gif 라는 파일이 img폴더에 있는 상태에서,
나타나게 하고 싶습니다.
도와주십시오 ㅠㅠ
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
$cols = 1; // 이미지 가로갯수 // 이미지 세로 갯수는 메인에서 지정(총 이미지 수)
$image_h = 1; // 이미지 상하 간격
$col_width = (int)(99 / $cols);
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb';
?>
<style type="text/css">
<!--
.data { font-family:돋움; font-size:8pt; color:#999999; }
-->
</style>
<table width="95" border="0" cellspacing="0" cellpadding="0">
<!-- 최신글 제목 -->
<tr>
<td align='center' width="95">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<? for ($i=0; $i<count($list); $i++) {
if ($i>0 && $i%$cols==0) { echo "</tr><tr><td colspan='$cols' height='$image_h'></td></tr><tr>"; }
?>
<td width="100%" align="center" valign='top' height="15">
<?
$image = $list[$i][file][0][file]; //원본
$img=$data_path. "/".$image; //썸네일이 없을경우 원본출력
$thumb = $thumb_path. "/". $list[$i][file][0][file];
if ( file_exists($thumb))
$img = $thumb;
$style = "font-family:돋움; font-size:8pt; color:#636363;";
if ($list[$i][icon_new])
$style = "style='font-family:돋움; font-size:8pt; color:#424542;' ";
$subject = "<span $style>".cut_str($list[$i][subject],30)."</span>"; //제목 글자수 자르기
$bg = ""; //새글?
if ($list[$i][icon_new])
$bg="la_top_2.gif";
else
$bg="la_top_1.gif";
echo $list[$i][icon_reply] . " ";
echo "<table width='75' cellpadding='0' cellspacing='0' border='0'>";
echo "<tr><td valign='top' align='center'><a href='{$list[$i]['href']}' onFocus=\"this.blur();\" title=\"{$list[$i][subject]}\"><img src='$img' width='95' height='60' border='0'></a></td></tr>";
echo "<tr><td height='21' align='center'><a href='{$list[$i]['href']}'><b><span style='font-size:10pt;'><font color='#424542'>{$subject}</font></span></b></a></td></tr></table>";
?>
</td>
<? } ?>
<?
$cnt = ($i%$cols);
for ($k=$cnt; $k<$cols && $cnt; $k++) {
echo "<td width=$col_width%> </td>";
}
?>
<? if (count($list) == 0) { echo "<td height=80 align=center>게시물이 없습니다.</td>"; } ?>
</tr>
</table></td>
</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>
원문이구요.
첨부된 이미지 파일이 없을때 noimg.gif 라는 파일이 img폴더에 있는 상태에서,
나타나게 하고 싶습니다.
도와주십시오 ㅠㅠ
|
댓글을 작성하시려면 로그인이 필요합니다.
로그인
댓글 8개
$img=$data_path. "/".$image; //썸네일이 없을경우 원본출력
여기를
$img = $g4['path']."/img/noimg.gif";
일케 하면 될듯하네여
if ( file_exists($thumb) ) {
$img = $thumb;
}else{
$img = "/img/noimg.gif";
}
이방법도 해봤지만 역시 엑박 뜹니다 ㅠㅠ
$img = $thumb;
}else{
$img = "/img/noimg.gif";
}
이렇게 하실꺼면 아마 이미지가 /bbs/img이어야하고요
루트/img 안에 있다면
"$g4[path]/img/noimg.gif";
로 하셔야 합니다.
엑박뜨는곳에서 오른쪽메뉴에서 속성을 보시면 이미지 경로가 나올껍니다.
그걸 복사하셔서 브라우저의 주소창에 붙여넣기 해보세요
실제경로와 다르게 나온다면 수정하시고
주소줄에 넣었을때는 제대로 나온다면 다시 리플남겨주세요.
으로 나와요. 근본이 잘못된건가요?
file_exists($thumb) 이부분이 문제였습니다.
file_exists 를 쓰면 디렉토리도 파일로 인식하는 OS시스템에서 존재한다고 판단하는 것 같습니다.
file_exists($thumb) 대신에
is_file($thumb) 로 해보세요.
그래도 안되면 리플남겨주세요.
메가쵸코님 이렇게 고생해주시는데, 정말 송구스럽네요 ㅠㅠ
제가 답드린것이 썸네일이 항상 만들어진다고 가정해서 그렇구요
썸네일이 무조건 생성되지 않는 거라면 다음과 같이 하시면 될 듯 합니다.
<?
$image = $list[$i][file][0][file]; //원본
$img=$data_path. "/".$image; //썸네일이 없을경우 원본출력
$thumb = $thumb_path. "/". $list[$i][file][0][file];
if (is_file($thumb)) {
$img = $thumb;
}else if(!is_file($img)){
$img="$g4[path]/img/noimg.gif";
}
이렇게 해보시기 바랍니다.
진짜 수고 하셨습니다.
존경합니다 메가쵸코님 ㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠ