본문에 링크 된 이미지를 최신글에 나타내기 > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

본문에 링크 된 이미지를 최신글에 나타내기 정보

본문에 링크 된 이미지를 최신글에 나타내기

본문

모닝님의 최신글 소스입니다.

여기서 에디터로 올린내용 중 링크된 이미지를 썸네일로 불러오는 방법이 없을까요?

본문링크 이미지는 아래 링크의 샤방S님의 외부 이미지 저장하기 팁으로 불러오고 있습니다.

http://sir.co.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=21620&sca=&sfl=wr_subject%7C%7Cwr_content&stx=%B8%B5%C5%A9+%C0%CC%B9%CC%C1%F6+%C0%FA%C0%E5&sop=and

몇일 째 연구해 보았지만 실력이 짧아서 도저히 안되네요.

wr_content 의 내용의 링크를 preg_match 같은 걸로 변환하면 될 것 같은데.. 실력이 미천해서

고수님들의 조언 꼭 부탁드립니다.



<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가

// 썸네일방식은 유창화님의 소스.

include_once "$g4[path]/lib/image_proc.function.php";

//경로 변수 설정
$path_data = $g4['path'] . '/data/file/' . $bo_table;
$path_data_thumb = $path_data . '/thumb';

//디렉토리 생성 여부 확인 및 생성, 퍼미션 조정
if (!is_dir($path_data_thumb)){

  @mkdir($path_data_thumb, 0707);
  @chmod($path_data_thumb, 0707);
}

$thumb_print_num = $thumb_lines;//썸네일 출력 갯수
$thumb_save_w = 105; // 썸네일 넓이
$thumb_save_h = 70; // 썸네일 높이

$letters1 = '120'; // 그림있을 경우 글자수(아래처럼 적당한 숫자가능)
$letters2 = '180'; // 그림없을 경우 글자수
?>

<STYLE>P.BigFirst:first-letter { color:red; font-size: 200%; float: left; padding:7 7 7 3; }</STYLE>

<table width=100% cellpadding=0 cellspacing=3 style="border:1 solid #FFCC00;">
<tr>
<td width=2></td>
    <td bgcolor="#A7CE31" width="10"></td>
<td height=17 valign="bottom">&nbsp;&nbsp;
<a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>' style="font-size:13px;text-decoration:none;"><b><?=$board[bo_subject]?></b></a>
</td>
</tr>
</table>
<table width=100% border='0' cellspacing='0' cellpadding='0'>
<?
$list_cnt = count($list);
for ($i = 0; $i < $list_cnt; $i++){ 

  if($i >= 0 && $i < $thumb_print_num) {//처음부터 $thumb_print_num 까지 썸네일 출력
 
if ($i > 0) { echo "<tr><td height=1 background='$g4[path]/img/dot_line.gif'></td></tr>"; }

    $wr_content = preg_replace("/<(.*?)\>/", ' ', $list[$i]['wr_content']);
    $wr_content = preg_replace("/&nbsp;/", ' ', $wr_content);
    $wr_content = str_replace("//##", ' ', $wr_content);

    $path_save_file = '';
    $name_src_file = $list[$i]['file'][0]['file'];  //첫번째 이미지 파일로 지정

    if (preg_match("/\.(gif|jpe?g|png)$/i", $name_src_file)){

      $thumb_options['crop_use'] = 1;

      if ($options ==1){ $thumb_save_h = 0;} //너비 기준 정비율 리사이즈

      if ($options ==2){ $thumb_save_w = 0;} //높이 기준 정비율 리사이즈

      if ($options ==3){//너비 기준은 가운데, 높이 기준은 상단으로 크롭

        $thumb_options['crop_pos_width'] = 2; // 1 좌, 2 가운데, 3 우
        $thumb_options['crop_pos_height'] = 1; // 1 상, 2 중, 3 하
      }

      if ($options ==4){//너비 기준은 가운데, 높이 기준은 중앙으로 크롭

        $thumb_options['crop_pos_width'] = 2; // 1 좌, 2 가운데, 3 우
        $thumb_options['crop_pos_height'] = 2; // 1 상, 2 중, 3 하
      }


      $path_src_file = $path_data . '/' . $name_src_file;//원본파일
      $path_save_file = $path_data_thumb . '/' . $thumb_save_w . 'X' . $thumb_save_h . '_' . $options . '_' . $name_src_file;//썸네일 파일

      if (!file_exists($path_save_file)) {

        $result = thumnail_test1($path_src_file, $path_save_file, $thumb_save_w, $thumb_save_h, $thumb_options);

      }
    }


  $wr_content = preg_replace("/<(.*?)\>/"," ",$list[$i][wr_content]);
$wr_content = preg_replace("/&nbsp;/"," ",$wr_content);
$wr_content = str_replace("//##", " ", $wr_content);
$wr_content1 = cut_str(get_text($wr_content), $letters1, '…');
$wr_content2 = cut_str(get_text($wr_content), $letters2, '…');//본문 글 줄이는 함수
$href = $list[$i]['href'];
$num = $list[$i][num];

if (file_exists($path_save_file)) {

echo "<tr><td style='padding:5;'>";
echo "<span style='float:left' style='padding:5 5 0 5;'>
<a href='{$list[$i][href]}'><img src='$path_save_file' border=0></a></span>
&nbsp;<img src='{$latest_skin_path}/img/icon_li.gif' border='0' align='absmiddle'>&nbsp;
<a href='{$list[$i][href]}' style='text-decoration:none;'><b>{$list[$i][subject]}</b></a>";

if ($list[$i]['comment_cnt']) {
echo " <a href=\"{$list[$i]['comment_href']}\"><span style='font-family:돋움; font-size:8px; color:#9A9A9A;'>{$list[$i]['comment_cnt']}</span></a>";
echo " " . $list[$i]['icon_new'];
echo " " . $list[$i]['icon_file'];
echo " " . $list[$i]['icon_link'];
echo " " . $list[$i]['icon_hot'];
echo " " . $list[$i]['icon_secret'];
}

echo "<br><div align='justify' style='margin-right:1; margin-left:1;'><a href='{$list[$i][href]}' style='line-height:130%;text-decoration:none;'>$wr_content1</a>&nbsp;<span style='font-family:돋움;color:#9A9A9A;'>{$list[$i][datetime2]}</span></div>";
echo "</td></tr>";
}
else {
echo "<tr><td  style='padding:5 0 0 5;'>";
echo "&nbsp; <img src='{$latest_skin_path}/img/icon_li.gif' border='0' align='absmiddle'>&nbsp;<a href='{$list[$i][href]}' style='text-decoration:none;'><b>{$list[$i][subject]}</b></a>";

if ($list[$i]['comment_cnt']) {
echo " <a href=\"{$list[$i]['comment_href']}\"><span style='font-family:돋움; font-size:8pt; color:#9A9A9A;'>{$list[$i]['comment_cnt']}</span></a>";
echo " " . $list[$i]['icon_new'];
echo " " . $list[$i]['icon_file'];
echo " " . $list[$i]['icon_link'];
echo " " . $list[$i]['icon_hot'];
echo " " . $list[$i]['icon_secret'];
}

echo "</td></tr>";
echo "<tr><td style='padding:0 5 5 5;'>";
echo "<div align='justify' style='margin-right:1; margin-left:1;'><P class='BigFirst'><a href='{$list[$i][href]}' style='line-height:130%;text-decoration:none;'>$wr_content2</a>&nbsp;<span style='font-family:돋움;color:#9A9A9A;'>{$list[$i][datetime2]}</span></P></div>";

/* echo "<div align='justify' style='margin-right:1; margin-left:1;'><a href='{$list[$i][href]}' style='font-size:10px; line-height:170%; text-decoration:none;'>$wr_content2</a>&nbsp;{$list[$i][datetime2]}</div>";
*/
echo "</td></tr>";
}

else {
if ($i == $thumb_print_num) { echo "<tr><td height=1 background='$g4[path]/img/dot_line.gif'></td></tr>"; }
echo "<tr><td height='20' align='left'>";
echo "&nbsp; <img src='{$latest_skin_path}/img/icon_li.gif' border='0' align='absmiddle'> <a href='{$list[$i][href]}' style=';text-decoration:none;'>{$list[$i][subject]}</a>&nbsp;&nbsp;<span style='font-family:돋움;color:#9A9A9A;'>{$list[$i][datetime2]}</span>";

if ($list[$i]['comment_cnt']) {
echo " <a href=\"{$list[$i]['comment_href']}\"><span style='font-family:돋움; font-size:8pt; color:#9A9A9A;'>{$list[$i]['comment_cnt']}</span></a>";
echo " " . $list[$i]['icon_new'];
echo " " . $list[$i]['icon_file'];
echo " " . $list[$i]['icon_link'];
echo " " . $list[$i]['icon_hot'];
echo " " . $list[$i]['icon_secret'];
}
echo "</td></tr>";
}
}
?>
</table>
  • 복사

댓글 전체

답변 감사합니다. preg_match 로 몇일 째 뽑아내 보고 있습니다.
 잘 안되서요.
wr_content 의 내용 중 이미지는 아래와 같이 표현됩니다.
<IMG src="../data/geditor/1010/1285818585_OAaT6IH0_00000000000001_uIvTAHEt.jpg">
<IMG src="http://www.aaa.co.kr/data/geditor/1010/2040674069_9e804a50_desk8.jpg">
또는
<P style="TEXT-ALIGN: left"><IMG class=tx-daum-image id=A_194EA51E4BB00280B3EA70 style="CLEAR: none; FLOAT: none; WIDTH: 700px" hspace=1 src="http://aaa.co.kr/data/cheditor4/1009/194EA51E4BB00280B3EA70_w6EBH1w9U1UX" width=1024 vspace=1 border=0 actualwidth="1024">
© SIRSOFT
현재 페이지 제일 처음으로