최신글 스킨을 이용하여 특정 그룹 최신글 출력시 썸네일 중첩되는 현상 해결좀 부탁드려요! 정보
최신글 스킨을 이용하여 특정 그룹 최신글 출력시 썸네일 중첩되는 현상 해결좀 부탁드려요!관련링크
본문
위와 같이 게시판 여러개가 속한 그룹최신글을 불러올때
썸네일이 중복되어 표기 되는 오류 누가 좀 해결방법 좀 알려주세요 ^^;
?=mw_latest_group() <--- 그룹추출
?=mw_latest_multi() <--- 게시판 여러개 지정 추출
둘다 같은 현상이 일어납니다.
단, 하나의 게시판을 불러올때는 정상[ mw_latest(), latest() ]
그룹으로 썸네일을 뽑아 올 경우 게시판 테이블은 다른데 wr_id 값이 같은 게시판은 동일한 썸네일이 생성되어 뿌려지네요 ㅠㅠ
어떻게 해결 방법이 없을까요?
아래가 현재 제가 사용중인 최신글 스킨 소스입니다!
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 갤러리 게시판 입니다.");
$cols = 6; // 이미지 가로갯수 // 이미지 세로 갯수는 메인에서 지정(총 이미지 수)
$img_width = '112'; //썸네일 가로길이
$img_height = '134'; //썸네일 세로길이
$img_quality = '99'; //퀼리티 100이하로 설정
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb_shopping'; //썸네일 이미지 생성 디렉토리
$ym = date("ym", $g4[server_time]);
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
$col_width = (int)(100 / $cols);
?>
<!-- 최신글 제목 -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin-top:7px; margin-top:16px;">
<tr>
<? for ($i=0; $i<count($list); $i++) {
if ($i>0 && $i%$cols==0) { echo "</tr><tr><td colspan='$cols' height='$image_h'></td></tr><tr>"; }
?>
<td width="<?=$col_width?>%" align="center" valign='top'>
<?
$img = "";
$img = $thumb_path.'/'.$list[$i][wr_id];
// 썸네일 이미지가 존재하지 않는다면
if (!file_exists($img)) {
$file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];
// 업로드된 파일이 이미지라면
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($file)) {
$size = getimagesize($file);
if ($size[2] == 1)
$src = imagecreatefromgif($file);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($file);
else if ($size[2] == 3)
$src = imagecreatefrompng($file);
else
break;
$rate = $img_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
if ($height < $img_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $img_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
} else {
$edit_img = $list[$i]['wr_content'];
if (eregi("data/cheditor4/{$ym}/[^<>]*\.(gif|jpg|png|bmp)", $edit_img, $tmp)) { // data/geditor------
$file = './' . $tmp[0]; // 파일명
$size = getimagesize($file);
if ($size[2] == 1)
$src = imagecreatefromgif($file);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($file);
else if ($size[2] == 3)
$src = imagecreatefrompng($file);
else
break;
$rate = $img_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
if ($height < $img_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $img_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
}
}
}
if (file_exists($img)){
$img = "<a href='{$list[$i][href]}'><img src='$img' width='$img_width' height='$img_height' border='0' style='border:1 #eee solid' onmouseover=this.style.filter='alpha(opacity=60)' onmouseout=this.style.filter='' title='{$list[$i][subject]}'></a>";
} else {
//이미지가 없으면
$img="<img src='$latest_skin_path/img/noimg.gif' width='{$img_width}' height='{$img_height}' style='border:1 #E7E7E7 solid'></a>";
//이미지가 아니네
if(preg_match("/\.(swf|wma|asf)$/i","$file") && file_exists($file)) $img = "<script>doc_write(flash_movie('$file', 'flash$i', '$img_width', '$img_height', 'transparent'));</script>";
}
?><a href='<?=$list[$i][href]?>'><?=$img?></a>
<div style="margin:3px; padding:3px;"><a href="<?=$list[$i]['href']?>"><span style='font-size:9pt;'><?=$list[$i]['subject']?></span></div>
</td>
<? } ?>
<?
$cnt = ($i%$cols);
for ($k=$cnt; $k<$cols && $cnt; $k++) {
echo "<td width=$col_width%> </td>";
}
?>
<? if (count($list) == 0) { echo "<td align=center>게시물이 없습니다.</td>"; } ?>
</tr>
</table>
ps. 참고로 배추빌더를 이용중입니다!
댓글 전체
에서 만드세요
그리고 최신글에서는 이미 만들어진 썸네일을 그냥 불러오는 방식을 취하시면 될꺼 같습니다~
http://sir.co.kr/bbs/board.php?bo_table=g4_pi_thumb
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
include_once("$g4[path]/lib/thumb.lib.php");
$cols = 6; // 이미지 가로갯수 // 이미지 세로 갯수는 메인에서 지정(총 이미지 수)
$img_width = '112'; //썸네일 가로길이
$img_height = '134'; //썸네일 세로길이
$img_quality = '70'; //퀼리티 100이하로 설정
$data_path = $g4[path]."/data/file/$bo_table";
$col_width = (int)(100 / $cols);
?>
<!-- 최신글 제목 -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin-top:7px; margin-top:16px;">
<tr>
<? for ($i=0; $i<count($list); $i++) {
if ($i>0 && $i%$cols==0) { echo "</tr><tr><td colspan='$cols' height='$image_h'></td></tr><tr>"; }
?>
<td width="<?=$col_width?>%" align="center" valign='top'>
<?
$file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];
$img = thumbnail($file, $img_width, $img_height, $img_quality);
$img = "<a href='{$list[$i][href]}'><img src='$img' width='$img_width' height='$img_height' border='0' style='border:1 #eee solid' onmouseover=this.style.filter='alpha(opacity=60)' onmouseout=this.style.filter='' title='{$list[$i][subject]}'></a>";
?><a href='<?=$list[$i][href]?>'><?=$img?></a>
<div style="margin:3px; padding:3px;"><a href="<?=$list[$i]['href']?>"><span style='font-size:9pt;'><?=$list[$i]['subject']?></span></div>
</td>
<? } ?>
<?
$cnt = ($i%$cols);
for ($k=$cnt; $k<$cols && $cnt; $k++) {
echo "<td width=$col_width%> </td>";
}
?>
<? if (count($list) == 0) { echo "<td align=center>게시물이 없습니다.</td>"; } ?>
</tr>
</table>
근데 썸네일 이미지가 없을때 노이미지 출력하려고 하면 소스 어떻게 적용시켜야 하나요?
---
// 프로그램 : 불당썸 2.0.x
// 개 발 자 : 아빠불당 (http://kr.php.net/imagefilter
// $filter[type], [arg1] ... [arg4]
// $noimg : $noimg(이미지파일)
// $thumb_type : 저장할 썸네일의 형식 (jpg/gif/png. 나머지는 원본대로)
/*
thumbnail의 if 로직입니다. 구조화 되지 않고 너무 많은 if를 써버렸습니다. ㅠ..ㅠ...
$width에 값이 있으면
- $height에 값이 있으면
- $width > 이미지크기
- $height > 이미지크기 : 이미지 크기대로 썸을 생성
- else
- $is_crop : 크롭
- else : 비율대로 썸을 생성
- else
$ratio로 $height를 구해서,
- $height > $tmp_y : 비율대로 썸 생성 (높이가 좀 부족 합니다) <-- 이부분에서 높이를 맞추고 넓기를 crop하자는 의견도 있어요
- else : 이미지 비율로 조정한 후 높이를 crop
- $height에 값이 없으면 (crop 하지 않습니다)
- $width가 이미지 크기보다 더 크면 : 이미지 크기대로 썸을 생성
- else : 비율대로 썸을 생성
$width에 값이 없으면 (높이로만 정렬하는 갤러리의 경우)
- $height가 이미지 크기보다 더 크면 : 이미지 크기대로 썸을 생성
- else
- $is_crop : crop
- else : 비율대로 썸을 생성
*/
function thumbnail($file_name, $width=0, $height=0, $is_create=false, $is_crop=2, $quality=70, $small_thumb=true, $watermark="", $filter="", $noimg="", $thumb_type="")