갤러리 리스트 썸네일을 이미지가 아닌 배경이미지로 표현 부탁드립니다. 채택완료
bossbug
4년 전
조회 4,893
안녕하세요. 고수님들
갤러리 리스트에서 썸네일을 이미지로 아래 코드로 불러오게 되어 있는데요.
</p>
<p>$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;</p>
<p>
이 부분을 아래 처럼 해 보았는데 안되더라고요.
background-image:url(이미지) contatin 로 불러오고 싶습니다.
부탁드립니다.
</p>
<p>$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;</p>
<p>
댓글을 작성하려면 로그인이 필요합니다.
답변 3개
채택된 답변
+20 포인트
4년 전
올려주신 소스는 정상적인 소스인데
$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로 바꿔보세요
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
4년 전
네 . 이렇게 처리했습니다. 감사합니다.
</p>
<p>$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;</p>
<p>
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인