갤러리 리스트 썸네일을 이미지가 아닌 배경이미지로 표현 부탁드립니다.

갤러리 리스트 썸네일을 이미지가 아닌 배경이미지로 표현 부탁드립니다.

QA

갤러리 리스트 썸네일을 이미지가 아닌 배경이미지로 표현 부탁드립니다.

본문

안녕하세요. 고수님들

 

갤러리 리스트에서 썸네일을 이미지로 아래 코드로 불러오게 되어 있는데요.

 

 


$thumb = get_list_thumbnail($board['bo_table'], $list[$i]['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height'], false, true);
                        
                        if($thumb['src']) {
                            $img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" >';
                            } else {
                            $img_content = '<i>이미지가 없습니다.</i>';
                            }
                        echo $img_content;

 

이 부분을 아래 처럼 해 보았는데 안되더라고요.

 

background-image:url(이미지) contatin  로 불러오고 싶습니다.

 

부탁드립니다.

 


$thumb = get_list_thumbnail($board['bo_table'], $list[$i]['wr_id'], false, true);
                        
                        if($thumb['src']) {
                            $style=';background:url(\''.$thumb['src'].'\') no-repeat center center;background-size:contain;';
                            $img_content = '<span style="width:'.$board['bo_gallery_width'].'px;height:'.$board['bo_gallery_height'].'px;'.$style.'"></span>';
                            } else {
                            $img_content = '<i>이미지가 없습니다.</i>';
                            }
                        echo $img_content;

이 질문에 댓글 쓰기 :

답변 3

올려주신 소스는 정상적인 소스인데

 

$thumb = get_list_thumbnail($board['bo_table'], $list[$i]['wr_id'], false, true);
                        
                        if($thumb['src']) {
                            $style=';background:url(\''.$thumb['src'].'\') no-repeat center center;background-size:contain;';
                            $img_content = '<span style="width:'.$board['bo_gallery_width'].'px;height:'.$board['bo_gallery_height'].'px;'.$style.'"></span>';
                            } else {
                            $img_content = '<i>이미지가 없습니다.</i>';
                            }
                        echo $img_content;

 

span 을 div로 바꿔보세요

block 요소로 해야 width height가 적용되지 않을까요? 

<span> style에 display: block; 이나 display: inline-block; 

혹은  <span> 대신 <div>

네 . 이렇게 처리했습니다. 감사합니다.


$thumb = get_list_thumbnail($board['bo_table'], $list[$i]['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height'], false, true);
                        
     $style=';background:url(\''.$thumb['src'].'\') no-repeat center center;background-size:contain;';
     $img_content = '<div style="margin:0 auto;;width:'.$board['bo_gallery_width'].'px;height:'.$board['bo_gallery_height'].'px;'.$style.'"></div>';
       } else {
      $img_content = '<i>이미지가 없습니다.</i>';
      }
      echo $img_content;
답변을 작성하시기 전에 로그인 해주세요.
전체 49
QA 내용 검색

회원로그인

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