이미지만 뽑아오기 채택완료
에디터로 댓글에 첨부한 이미지를 뽑아오려고
아래처럼 하니 나오긴 하는데..텍스트까지 함께 나옵니다.
0 "; /*여러개의 글 검사 할 때*/ $result = sql_query($query); for($j=0; $row = sql_fetch_array($result); $j++) {
echo get_view_thumbnail($row['wr_content'], $board['bo_gallery_width'], false); } } ?>
$row['wr_content']의 이미지만 뽑으려면 위 코드를 어떻게 해줘야 할까요?
답변 2개
아래코드에서 $matches[1]에 img태그들 배열로 들어가있습니다.
preg_match_all("/]*src=[\"']?([^>\"']+)[\"']?[^>]*>/i", $row['wr_content'],$matches);
echo $matches[1][0];
답변에 대한 댓글 3개
그래서 강제로 <img src="<? ~~ ?>"> 이렇게 위코드를 다 집어넣으니 출력되긴 합니다. 근데윈도우 오픈까지 해야 하는데..웬지 바른 방법이 아닌거 같아서요,,
댓글을 작성하려면 로그인이 필요합니다.
echo get_view_thumbnail($matches[1][0]);
get_view_thumbnail 이 함수가 url을 썸네일로 보여주는 함수인것 같으니 형식이 어떻게 들어가는지
하드코딩으로 체크해보시면 될것 같습니다.
get_view_thumbnail("http://xxx/aaa.jpg");
양식에 맞추어 넣으면 되지 않을까요?
url까지는 나온다고 하시니 안되면 댓글주세요..
답변에 대한 댓글 1개
<div class="gall_con">
<img style="cursor:pointer;" src=" <?php
if (!$list[$i]['is_notice']) {
$query = " select wr_content from ".$write_table." where wr_parent = '".$list[$i]['wr_id']."' and wr_is_comment > 0 ";
/*여러개의 글 검사 할 때*/
$result = sql_query($query);
for($j=0; $row = sql_fetch_array($result); $j++) {
preg_match_all("/<img[^>]*src=[\"']?([^>\"']+)[\"']?[^>]*>/i", $row['wr_content'],$matches);
echo get_view_thumbnail($matches[1][0], $board['bo_gallery_width'], false);
}
/*여러개의 글 검사 할 때*/
//$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'].'" class="list_img">';
// }
// echo $img_content;
}
?>" onclick="window.open('<?php
if (!$list[$i]['is_notice']) {
$query = " select wr_content from ".$write_table." where wr_parent = '".$list[$i]['wr_id']."' and wr_is_comment > 0 ";
/*여러개의 글 검사 할 때*/
$result = sql_query($query);
for($j=0; $row = sql_fetch_array($result); $j++) {
preg_match_all("/<img[^>]*src=[\"']?([^>\"']+)[\"']?[^>]*>/i", $row['wr_content'],$matches);
echo get_view_thumbnail($matches[1][0], $board['bo_gallery_width'], false);
}
/*여러개의 글 검사 할 때*/
//$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'].'" class="list_img">';
// }
// echo $img_content;
}
?>','asd','scrollbars=yes,width=650,height=750,top=10,left=20');">
</div>
그걸 위해 이렇게 되었습니다. src=""에 넣어야 하니 그렇고,,뒤에 window.open으로 띄우려니 이렇게 정말 복잡해졌습니다..ㅋ
나오긴 나옵니다.
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
제 코드에는 어떻게 넣어야 할 지 몰라서..버벅거리고 있습니다.
for($j=0; $row = sql_fetch_array($result); $j++) {
preg_match_all("/<img[^>]*src=[\"']?([^>\"']+)[\"']?[^>]*>/i", $row['wr_content'],$matches);
echo get_view_thumbnail($matches[1][0]);
}
이렇게 하니 <img 이게 없이
https://~~~ 이렇게 하니 url만 나와서
섬네일 표출이 안되는데..어떻게 해야 할지요,,