본문에서 썸네일의 이미지가 없을시 노이미지 출력을 어떻게 해야할까요?
본문
function get_thumbnail2($bo_table, $img, $width, $height=0, $alt, $view=0)
{
$str = '';
$file = G5_DATA_PATH.'/file/'.$bo_table.'/'.$img;
if(is_file($file))
$size = @getimagesize($file);
if($size[2] < 1 || $size[2] > 3)
return '';
$img_width = $size[0];
$img_height = $size[1];
$filename = basename($file);
$filepath = dirname($file);
if($img_width && !$height) {
$height = round(($width * $img_height) / $img_width);
}
$thumb = thumbnail($filename, $filepath, $filepath, $width, $height, false, false, 'center', true, $um_value='80/0.5/3');
if($thumb) {
$file_url = str_replace(G5_PATH, G5_URL, $filepath.'/'.$thumb);
$str = '<a href="'.$file_url.'" target="_blank" class="popup_item_image"><img src="'.$file_url.'" alt="'.$alt.'"></a>';
}
if($view == 1) return $str;
}
<div id="sit_pvi_big">
<?php for($i = 0; $i <= count($view['file']); $i++) { // 이미지 뷰 ?>
<?php if($view['file'][$i]['file']){
get_thumbnail2($bo_table, $view['file'][$i]['file'], 400, 300, $view['file'][$i]['bf_content']);
?>
<?php echo get_thumbnail2($bo_table, $view['file'][$i]['file'], 400, 300, $view['file'][$i]['bf_content'], 1); ?>
<?php } ?>
<?php } ?>
</div>
<div id="sit_pvi_thumb">
<?php for($i = 0; $i <= count($view['file']); $i++) { // 이미지 뷰 ?>
<?php if($view['file'][$i]['file']){
get_thumbnail($bo_table, $view['file'][$i]['file'], 400, 300, $view['file'][$i]['bf_content']);
?>
<?php echo get_thumbnail($bo_table, $view['file'][$i]['file'], 60, 60, $view['file'][$i]['bf_content'], 1); ?>
<?php } ?>
<?php } ?>
</div>
답변 1
if($thumb) {
$file_url = str_replace(G5_PATH, G5_URL, $filepath.'/'.$thumb);
$str = '<a href="'.$file_url.'" target="_blank" class="popup_item_image"><img src="'.$file_url.'" alt="'.$alt.'"></a>';
}
를 이렇게 하면 될듯 싶네요
if($thumb) {
$file_url = str_replace(G5_PATH, G5_URL, $filepath.'/'.$thumb);
$str = '<a href="'.$file_url.'" target="_blank" class="popup_item_image"><img src="'.$file_url.'" alt="'.$alt.'"></a>';
} else {
$str = '<a href="'.$file_url.'" target="_blank" class="popup_item_image"><img src="'.$board_skin_url.'/img/noimg.gif" alt="'.$alt.'"></a>';
}
스킨 폴더에 noimg.gif 이미지를 올려주시구요