첨부파일이 아닌 에디터로 삽입한 첫번째 이미지를 리스트에 출력하는 법. 정보
첨부파일이 아닌 에디터로 삽입한 첫번째 이미지를 리스트에 출력하는 법.첨부파일
본문
제목 그대로 cheditor 에서, 또는 html 코드를 이용하여 <img src="어쩌구 저쩌구"> 라고 사용하여
내용에 이미지를 삽입했을 경우( html 사용이 가능하고 에디터 모드가 아닌 일반 글쓰기 모드.. 또는 에디터 모드에서 ) 리스트에 이미지가 출력되는 방법을 찾습니다.
예전에는 게시판이 에디터보다는 텍스트 위주이다 보니 첫번째 첨부파일 이미지를 리스트에 출력한것 같습니다.
첫번째 첨부파일은 제가 사용하는 이미지 게시판이고
두번째와 세번째 첨부파일은 말씀드린 방식으로 동작이 되고 있는 게시판 입니다.
코드를 아무리 보고 이리 붙여보고 저리붙여봐도 에러만 나고 되지를 않습니다. ㅜ.ㅡ
php를 알지를 못하니.. 흙 ㅜ.ㅡ
" 부분이 이래서 문제인것 같고 이 부분을 어떻게 수정해야 하죠? " 라고 질문을 드릴 능력조차 되지 않아서
감히 조심스럽게 첨부파일로 질문을 드립니다.
두번째 와 세번째 파일의 경우는 첨부파일이 이미지일 경우 출력하고 이미지가 아닐경우에는 내용에 들어있는 이미지 중 첫번째 이미지를 출력하는경우인데
두번째는 첨부파일 이미지가 아닐경우에는 썸네일을 생성하지 않는것 같습니다.
썸네일로 생성이 되는것은 세번째 첨부파일인것 같아서 해보았는데 .. ㅜ.ㅡ
어떻게 해야할지 도움좀 부탁드립니다.
너무 장황하고 핵심적인 내용을 기재하지 못해서 죄송합니다.
내용에 이미지를 삽입했을 경우( html 사용이 가능하고 에디터 모드가 아닌 일반 글쓰기 모드.. 또는 에디터 모드에서 ) 리스트에 이미지가 출력되는 방법을 찾습니다.
예전에는 게시판이 에디터보다는 텍스트 위주이다 보니 첫번째 첨부파일 이미지를 리스트에 출력한것 같습니다.
첫번째 첨부파일은 제가 사용하는 이미지 게시판이고
두번째와 세번째 첨부파일은 말씀드린 방식으로 동작이 되고 있는 게시판 입니다.
코드를 아무리 보고 이리 붙여보고 저리붙여봐도 에러만 나고 되지를 않습니다. ㅜ.ㅡ
php를 알지를 못하니.. 흙 ㅜ.ㅡ
" 부분이 이래서 문제인것 같고 이 부분을 어떻게 수정해야 하죠? " 라고 질문을 드릴 능력조차 되지 않아서
감히 조심스럽게 첨부파일로 질문을 드립니다.
두번째 와 세번째 파일의 경우는 첨부파일이 이미지일 경우 출력하고 이미지가 아닐경우에는 내용에 들어있는 이미지 중 첫번째 이미지를 출력하는경우인데
두번째는 첨부파일 이미지가 아닐경우에는 썸네일을 생성하지 않는것 같습니다.
썸네일로 생성이 되는것은 세번째 첨부파일인것 같아서 해보았는데 .. ㅜ.ㅡ
어떻게 해야할지 도움좀 부탁드립니다.
너무 장황하고 핵심적인 내용을 기재하지 못해서 죄송합니다.
댓글 전체
제가 사용하는 latest.skin.php 들중 하나를 그냥 그대로 올려봅니다.
<?
if (!defined("_GNUBOARD_")) exit;
include_once "$g4[path]/mkthumb/mkthumb.php";
$thumb_width=80;//섬네일 최대폭
$thumb_height=80;//섬네일 최대높이
?>
<table width=215 align=center cellpadding=0 cellspacing=0>
<tr><td colspan=3><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><img src='<?=$latest_skin_path?>/img/<?=$bo_table?>_more.gif' border=0></a></td></tr>
<? for ($i=0; $i<count($list); $i++) { ?>
<? if ($i==0){?>
<tr>
<?
$pos1= stristr($list[$i][wr_content],'<IMG');
$pos2= strpos($pos1,'>');
$result1= stristr(substr($pos1,0,$pos2+1),'http');
$pos3= strpos($result1,'"');
$thumbsource= stristr(substr($result1,0,$pos3),'http');
?>
<? if ($thumbsource) { ?>
<td valign=top>
<?
$thumbimg=$g4[path] . "/data/file/" . $bo_table . "/angul_" . $list[$i][wr_id].".thumb";
get_ThumbnailFromHTMLTag($thumb_width,$thumb_height,$thumbsource,$thumbimg);
@chmod($thumbimg, 0707);
$thum_img = "<img src='$thumbimg' width='".$thumb_width."' height='".$thumb_height."' style='border:1 #E7E7E7 solid' title='[{$list[$i][ca_name]}] {$list[$i][subject]}'>";
echo "<a href='{$list[$i][href]}'>$thum_img</a>";
?>
</td>
<? }else{?>
<!-----------첫번째 첨부파일에 이미지가 있으면 이미지 출력 //---------------->
<td valign=top>
<?
$image = urlencode($list[$i][file][0][file]);
if (preg_match("/\.(gif|jpg|png)$/i", $image)) {
$thumbsource=$g4[path] . "/data/file/" . $bo_table . "/" .$image;
$thumbimg=$g4[path] . "/data/file/" . $bo_table ."/angul_" . $list[$i][wr_id].".thumb";
make_thumb($thumb_width,$thumb_height,$thumbsource,$thumbimg);
@chmod($thumbimg, 0707);
$thum_img = "<img src='$thumbimg' width='".$thumb_width."' height='".$thumb_height."' style='border:1 #E7E7E7 solid' title='[{$list[$i][ca_name]}] {$list[$i][subject]}'>";
echo "<a href='{$list[$i][href]}'>$thum_img</a>";
} else
echo "<a href='{$list[$i][href]}'><img src='$latest_skin_path/img/noimage.gif' width='$thumb_width' height='$thumb_height' border=1 style='border-color:d1d1d1;' align=left hspace=10 vspace=0></a>";
?>
</td>
<? }?>
<? }else if ($i==1){?>
<?
$pos1= stristr($list[$i][wr_content],'<IMG');//첫번째 여는 이미지 태그부터 pos1에 담고
$pos2= strpos($pos1,'>');//첫번째 닫는 태그의 위치를 잡는다.
$result1= stristr(substr($pos1,0,$pos2+1),'http');
$pos3= strpos($result1,'"');
$thumbsource= stristr(substr($result1,0,$pos3),'http');
?>
<? if ($thumbsource) { ?>
<td valign=top>
<?
$thumbimg=$g4[path] . "/data/file/" . $bo_table . "/angul_" . $list[$i][wr_id].".thumb";
get_ThumbnailFromHTMLTag($thumb_width,$thumb_height,$thumbsource,$thumbimg);
@chmod($thumbimg, 0707);
$thum_img = "<img src='$thumbimg' width='".$thumb_width."' height='".$thumb_height."' style='border:1 #E7E7E7 solid' title='[{$list[$i][ca_name]}] {$list[$i][subject]}'>";
echo "<a href='{$list[$i][href]}'>$thum_img</a>";
?>
</td>
<? }else{?>
<!-----------첫번째 첨부파일에 이미지가 있으면 이미지 출력 //---------------->
<td valign=top>
<?
$image = urlencode($list[$i][file][0][file]);
if (preg_match("/\.(gif|jpg|png)$/i", $image)) {
$thumbsource=$g4[path] . "/data/file/" . $bo_table . "/" .$image;
$thumbimg=$g4[path] . "/data/file/" . $bo_table ."/angul_" . $list[$i][wr_id].".thumb";
make_thumb($thumb_width,$thumb_height,$thumbsource,$thumbimg);
@chmod($thumbimg, 0707);
$thum_img = "<img src='$thumbimg' width='".$thumb_width."' height='".$thumb_height."' style='border:1 #E7E7E7 solid' title='[{$list[$i][ca_name]}] {$list[$i][subject]}'>";
echo "<a href='{$list[$i][href]}'>$thum_img</a>";
} else
echo "<a href='{$list[$i][href]}'><img src='$latest_skin_path/img/noimage.gif' width='$thumb_width' height='$thumb_height' border=1 style='border-color:d1d1d1;' align=left hspace=10 vspace=0></a>";
?>
</td>
<? }?>
</tr>
<? }else{?>
<tr><td colspan=3 height=5></td></tr>
<tr>
<td colspan=3 align=center>
<table width=100% cellpadding=0 cellspacing=0>
<tr>
<td height=20 style='padding-left:10px;'><img src='<?=$latest_skin_path?>/img/latest_icon.gif' align=absmiddle>
<?
echo $list[$i]['icon_reply'] . " ";
echo "<a href='{$list[$i]['href']}'>";
if ($list[$i]['is_notice'])
echo "<font style='font-family:돋움; font-size:9pt; color:#2C88B9;'><strong>{$list[$i]['subject']}</strong></font>";
else
echo "<font style='font-family:돋움; font-size:9pt; color:#6A6A6A;'>{$list[$i]['subject']}</font>";
echo "</a>";
?></td></tr>
<tr><td height=5><img src='<?=$latest_skin_path?>/img/dot_line.gif'></td></tr>
</table></td>
</tr>
<? } ?>
<? } ?>
<? if (count($list) == 0) { ?><tr><td colspan=4 align=center height=50><font color=#6A6A6A>게시물이 없습니다.</a></td></tr><? } ?>
</table>
<?
if (!defined("_GNUBOARD_")) exit;
include_once "$g4[path]/mkthumb/mkthumb.php";
$thumb_width=80;//섬네일 최대폭
$thumb_height=80;//섬네일 최대높이
?>
<table width=215 align=center cellpadding=0 cellspacing=0>
<tr><td colspan=3><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><img src='<?=$latest_skin_path?>/img/<?=$bo_table?>_more.gif' border=0></a></td></tr>
<? for ($i=0; $i<count($list); $i++) { ?>
<? if ($i==0){?>
<tr>
<?
$pos1= stristr($list[$i][wr_content],'<IMG');
$pos2= strpos($pos1,'>');
$result1= stristr(substr($pos1,0,$pos2+1),'http');
$pos3= strpos($result1,'"');
$thumbsource= stristr(substr($result1,0,$pos3),'http');
?>
<? if ($thumbsource) { ?>
<td valign=top>
<?
$thumbimg=$g4[path] . "/data/file/" . $bo_table . "/angul_" . $list[$i][wr_id].".thumb";
get_ThumbnailFromHTMLTag($thumb_width,$thumb_height,$thumbsource,$thumbimg);
@chmod($thumbimg, 0707);
$thum_img = "<img src='$thumbimg' width='".$thumb_width."' height='".$thumb_height."' style='border:1 #E7E7E7 solid' title='[{$list[$i][ca_name]}] {$list[$i][subject]}'>";
echo "<a href='{$list[$i][href]}'>$thum_img</a>";
?>
</td>
<? }else{?>
<!-----------첫번째 첨부파일에 이미지가 있으면 이미지 출력 //---------------->
<td valign=top>
<?
$image = urlencode($list[$i][file][0][file]);
if (preg_match("/\.(gif|jpg|png)$/i", $image)) {
$thumbsource=$g4[path] . "/data/file/" . $bo_table . "/" .$image;
$thumbimg=$g4[path] . "/data/file/" . $bo_table ."/angul_" . $list[$i][wr_id].".thumb";
make_thumb($thumb_width,$thumb_height,$thumbsource,$thumbimg);
@chmod($thumbimg, 0707);
$thum_img = "<img src='$thumbimg' width='".$thumb_width."' height='".$thumb_height."' style='border:1 #E7E7E7 solid' title='[{$list[$i][ca_name]}] {$list[$i][subject]}'>";
echo "<a href='{$list[$i][href]}'>$thum_img</a>";
} else
echo "<a href='{$list[$i][href]}'><img src='$latest_skin_path/img/noimage.gif' width='$thumb_width' height='$thumb_height' border=1 style='border-color:d1d1d1;' align=left hspace=10 vspace=0></a>";
?>
</td>
<? }?>
<? }else if ($i==1){?>
<?
$pos1= stristr($list[$i][wr_content],'<IMG');//첫번째 여는 이미지 태그부터 pos1에 담고
$pos2= strpos($pos1,'>');//첫번째 닫는 태그의 위치를 잡는다.
$result1= stristr(substr($pos1,0,$pos2+1),'http');
$pos3= strpos($result1,'"');
$thumbsource= stristr(substr($result1,0,$pos3),'http');
?>
<? if ($thumbsource) { ?>
<td valign=top>
<?
$thumbimg=$g4[path] . "/data/file/" . $bo_table . "/angul_" . $list[$i][wr_id].".thumb";
get_ThumbnailFromHTMLTag($thumb_width,$thumb_height,$thumbsource,$thumbimg);
@chmod($thumbimg, 0707);
$thum_img = "<img src='$thumbimg' width='".$thumb_width."' height='".$thumb_height."' style='border:1 #E7E7E7 solid' title='[{$list[$i][ca_name]}] {$list[$i][subject]}'>";
echo "<a href='{$list[$i][href]}'>$thum_img</a>";
?>
</td>
<? }else{?>
<!-----------첫번째 첨부파일에 이미지가 있으면 이미지 출력 //---------------->
<td valign=top>
<?
$image = urlencode($list[$i][file][0][file]);
if (preg_match("/\.(gif|jpg|png)$/i", $image)) {
$thumbsource=$g4[path] . "/data/file/" . $bo_table . "/" .$image;
$thumbimg=$g4[path] . "/data/file/" . $bo_table ."/angul_" . $list[$i][wr_id].".thumb";
make_thumb($thumb_width,$thumb_height,$thumbsource,$thumbimg);
@chmod($thumbimg, 0707);
$thum_img = "<img src='$thumbimg' width='".$thumb_width."' height='".$thumb_height."' style='border:1 #E7E7E7 solid' title='[{$list[$i][ca_name]}] {$list[$i][subject]}'>";
echo "<a href='{$list[$i][href]}'>$thum_img</a>";
} else
echo "<a href='{$list[$i][href]}'><img src='$latest_skin_path/img/noimage.gif' width='$thumb_width' height='$thumb_height' border=1 style='border-color:d1d1d1;' align=left hspace=10 vspace=0></a>";
?>
</td>
<? }?>
</tr>
<? }else{?>
<tr><td colspan=3 height=5></td></tr>
<tr>
<td colspan=3 align=center>
<table width=100% cellpadding=0 cellspacing=0>
<tr>
<td height=20 style='padding-left:10px;'><img src='<?=$latest_skin_path?>/img/latest_icon.gif' align=absmiddle>
<?
echo $list[$i]['icon_reply'] . " ";
echo "<a href='{$list[$i]['href']}'>";
if ($list[$i]['is_notice'])
echo "<font style='font-family:돋움; font-size:9pt; color:#2C88B9;'><strong>{$list[$i]['subject']}</strong></font>";
else
echo "<font style='font-family:돋움; font-size:9pt; color:#6A6A6A;'>{$list[$i]['subject']}</font>";
echo "</a>";
?></td></tr>
<tr><td height=5><img src='<?=$latest_skin_path?>/img/dot_line.gif'></td></tr>
</table></td>
</tr>
<? } ?>
<? } ?>
<? if (count($list) == 0) { ?><tr><td colspan=4 align=center height=50><font color=#6A6A6A>게시물이 없습니다.</a></td></tr><? } ?>
</table>
감사합니다. 일단 제가 지금 자야하는 상황이라서 지금은 못해보고 내일 테스트 해보겠습니다.
어차피 코드를 본다 하여도... 에휴.. ㅜ.ㅡ 그래도 정말 감사합니다.
보여주신 코드로 열심히 삽질하여 성공하면 감사의 말씀 드릴께요. ( 마구 붙여보다 보면 될지도.. -_-;;; 디자이너의 비애.. 추륵 ㅜ.ㅡ )
어차피 코드를 본다 하여도... 에휴.. ㅜ.ㅡ 그래도 정말 감사합니다.
보여주신 코드로 열심히 삽질하여 성공하면 감사의 말씀 드릴께요. ( 마구 붙여보다 보면 될지도.. -_-;;; 디자이너의 비애.. 추륵 ㅜ.ㅡ )

처리해드렸습니다. ㅋㅋㅋㅋ
채택이전에.. 언넝 박스 사진 삭제해요.. ㅜ.ㅡ
야!!!!! ㅡ.ㅡ++++++
야!!!!! ㅡ.ㅡ++++++