첨부이미지가 없을시 no image로 보이도록 어떻게하나요?

첨부이미지가 없을시 no image로 보이도록 어떻게하나요?

QA

첨부이미지가 없을시 no image로 보이도록 어떻게하나요?

본문

안녕하세요.

SIR에서 여러모로 도움을 많이받고있습니다. 감사합니다~

 

또 한가지 도움을 받고자 글올립니다ㅜ

 

게시판 목록 썸네일에 첨부이미지가 없을경우 no image라고 보일 수 있도록 하고싶은데

어떻게 해야하는지 모르겠네요ㅜ


        <?php for ($i=0; $i<count($list); $i++) {
            if($i>0 && ($i % $bo_gallery_cols == 0))
                $style = 'clear:both;';
            else
                $style = '';
            if ($i == 0) $k = 0;
            $k += 1;
            if ($k % $bo_gallery_cols == 0) $style .= "margin:0 !important;";
   
   $thumb = get_list_thumbnail($board['bo_table'], $list[$i]['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height']);

 

   if($thumb['src']) {
    $img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" width="'.$board['bo_gallery_width'].'" height="'.$board['bo_gallery_height'].'">';
   } else {
    $img_content = '<p style="width: '.$board['bo_gallery_width'].'px;height:'.$board['bo_gallery_height'].'px">no image</p>';
   }   

 

 

어떻게하면 좋을까요? 방법좀 알려주세요 ㅜㅜ

 

5d7ca38b909608fe609833dc547a96c9_1444710556_3129.jpg
 

이 질문에 댓글 쓰기 :

답변 1

아래처럼 바꿔보세요 

/*

if($thumb['src']) {
    $img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" width="'.$board['bo_gallery_width'].'" height="'.$board['bo_gallery_height'].'">';
   } else {
    $img_content = '<p style="width: '.$board['bo_gallery_width'].'px;height:'.$board['bo_gallery_height'].'px">no image</p>';
   }  

*/ 

 

 

 $img_content = '<img src="'.$thumb['src'].'"  onerror=\'this.src="/images/no_img.png"\'   alt="'.$thumb['alt'].'" width="'.$board['bo_gallery_width'].'" height="'.$board['bo_gallery_height'].'">'; 

답변을 작성하시기 전에 로그인 해주세요.
전체 467
QA 내용 검색

회원로그인

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