썸네일 출력문제 질문 좀 드립니다. 정보
썸네일 출력문제 질문 좀 드립니다.본문
썸네일소스
<? for ($i=0; $i<count($list); $i++) {
$img = "<img src='$board_skin_path/img/noimage01.gif' width=28 height=28 border=0>";
$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 = $img_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
if ($height < $img_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $img_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagepng($dst, $thumb_path.'/'.$list[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
}
}
if (file_exists($thumb))
$img = "<img src='$thumb' width=28 height=28 border=0>";
?>
썸네일 출력소스
<?
echo "<a href='{$list[$i][href]}' onfocus=blur()>";
echo $img;
echo "</a>";
?>
여분필드7로 남녀구분소스
<? if ($list[$i][wr_7] == 'M') {?><img src=<?=$board_skin_path?>/img/list_002.gif width=22 height=14 border=0 align=absmiddle><? }?>
<? if ($list[$i][wr_7] == 'F') {?><img src=<?=$board_skin_path?>/img/list_001.gif width=22 height=14 border=0 align=absmiddle><? }?>
여기에서 첨부한 이미지가 없으면 썸네일 소스중에 아래의 소스로 노이미지가 출력됩니다.
$img = "<img src='$board_skin_path/img/noimage01.gif' width=28 height=28 border=0>";
이걸 노이미가 아닌 여분필드값으로 이미지가 나오게 하려면 어떻게 고칠면 되는지요?
즉 이미지 첨부가 없으면 남녀 구분해서 이미지를 출력하려구합니다.
글쓴이가 남자이면 남자아이콘 여자이면 여자아이콘 이렇게요.
고수님들 도움 좀 주세요^^
<? for ($i=0; $i<count($list); $i++) {
$img = "<img src='$board_skin_path/img/noimage01.gif' width=28 height=28 border=0>";
$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 = $img_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
if ($height < $img_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $img_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagepng($dst, $thumb_path.'/'.$list[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
}
}
if (file_exists($thumb))
$img = "<img src='$thumb' width=28 height=28 border=0>";
?>
썸네일 출력소스
<?
echo "<a href='{$list[$i][href]}' onfocus=blur()>";
echo $img;
echo "</a>";
?>
여분필드7로 남녀구분소스
<? if ($list[$i][wr_7] == 'M') {?><img src=<?=$board_skin_path?>/img/list_002.gif width=22 height=14 border=0 align=absmiddle><? }?>
<? if ($list[$i][wr_7] == 'F') {?><img src=<?=$board_skin_path?>/img/list_001.gif width=22 height=14 border=0 align=absmiddle><? }?>
여기에서 첨부한 이미지가 없으면 썸네일 소스중에 아래의 소스로 노이미지가 출력됩니다.
$img = "<img src='$board_skin_path/img/noimage01.gif' width=28 height=28 border=0>";
이걸 노이미가 아닌 여분필드값으로 이미지가 나오게 하려면 어떻게 고칠면 되는지요?
즉 이미지 첨부가 없으면 남녀 구분해서 이미지를 출력하려구합니다.
글쓴이가 남자이면 남자아이콘 여자이면 여자아이콘 이렇게요.
고수님들 도움 좀 주세요^^
댓글 전체
for 문 아래 $img 변수를 $img = "<img src='$board_skin_path/img/noimage01.gif' width=28 height=28 border=0>"; 로 지정해 준 후, 첨부 파일이 없어서, img 가 noimage01.gif 로 출력됩니다.
$img = "<img src='$board_skin_path/img/noimage01.gif' width=28 height=28 border=0>";
를
if ($list[$i][wr_7] == 'M')
{
$img = "<img src=<?=$board_skin_path?>/img/list_002.gif width=28 height=28 border=0>";
} else {
$img = "<img src=<?=$board_skin_path?>/img/list_001.gif width=28 height=28 border=0>";
}
로 바꾸시면 될 듯 합니다.
해보진 않았습니다^^;;; 저도 초보라........ ㅎㅎㅎㅎ (그누에는 고수님들이 넘 많으셔서;;;)
$img = "<img src='$board_skin_path/img/noimage01.gif' width=28 height=28 border=0>";
를
if ($list[$i][wr_7] == 'M')
{
$img = "<img src=<?=$board_skin_path?>/img/list_002.gif width=28 height=28 border=0>";
} else {
$img = "<img src=<?=$board_skin_path?>/img/list_001.gif width=28 height=28 border=0>";
}
로 바꾸시면 될 듯 합니다.
해보진 않았습니다^^;;; 저도 초보라........ ㅎㅎㅎㅎ (그누에는 고수님들이 넘 많으셔서;;;)
답변 감사합니다.
님께서 알려주신데로하니 잘되네요.
님소스로 해야겠네요^^;
전 이걸 지워버리고
$img = "<img src='$board_skin_path/img/noimage01.gif' width=28 height=28 border=0>";
단순 무식하게 출력부분에 요렇게 했었거든요^^;;
<? if (file_exists($thumb)) { ?>
<p><a href='<?=$list[$i][href]?>' onfocus=blur()><?=$img?></a></p>
<? } else { ?>
<? if ($list[$i][wr_7] == 'M') {?>
<p><a href='<?=$list[$i][href]?>' onfocus=blur()><img src=<?=$board_skin_path?>/img/man0a.gif width=28 height=28 border=0></a></p>
<? }?>
<? if ($list[$i][wr_7] == 'F') {?>
<p><a href='<?=$list[$i][href]?>' onfocus=blur()><img src=<?=$board_skin_path?>/img/woman0a.gif width=28 height=28 border=0></a></p>
<? }?>
<? } ?>
님께서 알려주신데로하니 잘되네요.
님소스로 해야겠네요^^;
전 이걸 지워버리고
$img = "<img src='$board_skin_path/img/noimage01.gif' width=28 height=28 border=0>";
단순 무식하게 출력부분에 요렇게 했었거든요^^;;
<? if (file_exists($thumb)) { ?>
<p><a href='<?=$list[$i][href]?>' onfocus=blur()><?=$img?></a></p>
<? } else { ?>
<? if ($list[$i][wr_7] == 'M') {?>
<p><a href='<?=$list[$i][href]?>' onfocus=blur()><img src=<?=$board_skin_path?>/img/man0a.gif width=28 height=28 border=0></a></p>
<? }?>
<? if ($list[$i][wr_7] == 'F') {?>
<p><a href='<?=$list[$i][href]?>' onfocus=blur()><img src=<?=$board_skin_path?>/img/woman0a.gif width=28 height=28 border=0></a></p>
<? }?>
<? } ?>