이미지만 뽑아오기

이미지만 뽑아오기

QA

이미지만 뽑아오기

본문

에디터로 댓글에 첨부한 이미지를 뽑아오려고

아래처럼 하니 나오긴 하는데..텍스트까지 함께 나옵니다.

<?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++) {

     echo get_view_thumbnail($row['wr_content'], $board['bo_gallery_width'], false); 
    }
      
 }
?>

 

$row['wr_content']의 이미지만 뽑으려면 위 코드를 어떻게 해줘야 할까요?

 

이 질문에 댓글 쓰기 :

답변 2

아래코드에서 $matches[1]에 img태그들 배열로 들어가있습니다. 

 

preg_match_all("/<img[^>]*src=[\"']?([^>\"']+)[\"']?[^>]*>/i", $row['wr_content'],$matches);

echo $matches[1][0];

감사합니다, 검색해보니 알려주신 코드를 본거 같은데...
제 코드에는 어떻게 넣어야 할 지 몰라서..버벅거리고 있습니다.

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만 나와서
섬네일 표출이 안되는데..어떻게 해야 할지요,,

https://도메인/이미지 정상경로.jpg 이렇게 이미지 url은 제대로 출력됩니다.

그래서 강제로 <img src="<? ~~ ?>"> 이렇게 위코드를 다 집어넣으니 출력되긴 합니다. 근데윈도우 오픈까지 해야 하는데..웬지 바른 방법이 아닌거 같아서요,,

echo  get_view_thumbnail($matches[1][0]); 
 

get_view_thumbnail 이 함수가 url을 썸네일로 보여주는 함수인것 같으니 형식이 어떻게 들어가는지

하드코딩으로 체크해보시면 될것 같습니다.

 

get_view_thumbnail("http://xxx/aaa.jpg");

양식에 맞추어 넣으면 되지 않을까요? 

 

url까지는 나온다고 하시니 안되면 댓글주세요..

 

 

 

 

관심 감사합니다~



 <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으로 띄우려니 이렇게 정말 복잡해졌습니다..ㅋ

나오긴 나옵니다.

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

회원로그인

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