첨부파일 순서 섬네일지정 정보
첨부파일 순서 섬네일지정본문
<?
for ($i=0; $i<count($list); $i++) {
$img = "<img src='{$board_skin_path}/img/noimage.gif' width={$img_width} height={$img_height} style='border:3px solid #eee;' title='noimage'>";//이미지가 없으면
$bg = $i%2 ? 0 : 1;
$file_name="";
$thumb = $thumb_path.'/'.$list[$i][wr_id];
// $thumb = $thumb_path.'/'.$list[$i][file][0][file];
for($k=0;$k<$list[$i][file]["count"];$k++){
if(preg_match("/jpg|gif|png|bmp|jpeg/i",$list[$i][file][$k][file])){
$file_name=$list[$i][file][$k][file];
break 1;
}
}
if ($i && $i%$mod==0)
echo "</tr><tr>";
//첨부된 파일이 있으면
if($file_name){
for($j=0; $j<$list[$i][file]["count"]; $j++){
if (!file_exists($thumb)) {
$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);
}
}
if (file_exists($thumb)){
$img = "<img src='$thumb' width='$img_width' height='$img_height' style='border:3px solid #eee;' />";
}
if($list[$i][file][$j][image_type] >= 1 && $list[$i][file][$j][image_type] <= 3) {
$list[$i][thumbnail][path] = $list[$i][file][$j][path];
$list[$i][thumbnail][name] = $list[$i][file][$j][file];
$list[$i][thumbnail][content] = $list[$i][file][$j][bf_content];
$list[$i][thumbnail][href] = $list[$i][thumbnail][path]."/".$list[$i][thumbnail][name];
$list[$i][thumbnail][src] = $list[$i][thumbnail][path]."/thumbnail/".$list[$i][thumbnail][name];
if(!is_file($list[$i][thumbnail][src])){
$list[$i][thumbnail][src] = $list[$i][thumbnail][path]."/".$list[$i][thumbnail][name];
// 이미지 비률 수정및 이미지 포멧방식 체크
list($r_width[$i]) = getimagesize($list[$i][thumbnail][src]);
}
break;
}
}
}
1번 2번 3번 4번 사진을 올리면 1번으로 섬네일 생성
그후 1번 2번을 수정으로 삭제하면
3번이 섬네일로 보여야 하는데 안되더군요 ㅠㅠ
1번 없으면 2번 없으면 3번 첨부가 있으면 섬네일로...하는 방법은 없을까요?
for ($i=0; $i<count($list); $i++) {
$img = "<img src='{$board_skin_path}/img/noimage.gif' width={$img_width} height={$img_height} style='border:3px solid #eee;' title='noimage'>";//이미지가 없으면
$bg = $i%2 ? 0 : 1;
$file_name="";
$thumb = $thumb_path.'/'.$list[$i][wr_id];
// $thumb = $thumb_path.'/'.$list[$i][file][0][file];
for($k=0;$k<$list[$i][file]["count"];$k++){
if(preg_match("/jpg|gif|png|bmp|jpeg/i",$list[$i][file][$k][file])){
$file_name=$list[$i][file][$k][file];
break 1;
}
}
if ($i && $i%$mod==0)
echo "</tr><tr>";
//첨부된 파일이 있으면
if($file_name){
for($j=0; $j<$list[$i][file]["count"]; $j++){
if (!file_exists($thumb)) {
$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);
}
}
if (file_exists($thumb)){
$img = "<img src='$thumb' width='$img_width' height='$img_height' style='border:3px solid #eee;' />";
}
if($list[$i][file][$j][image_type] >= 1 && $list[$i][file][$j][image_type] <= 3) {
$list[$i][thumbnail][path] = $list[$i][file][$j][path];
$list[$i][thumbnail][name] = $list[$i][file][$j][file];
$list[$i][thumbnail][content] = $list[$i][file][$j][bf_content];
$list[$i][thumbnail][href] = $list[$i][thumbnail][path]."/".$list[$i][thumbnail][name];
$list[$i][thumbnail][src] = $list[$i][thumbnail][path]."/thumbnail/".$list[$i][thumbnail][name];
if(!is_file($list[$i][thumbnail][src])){
$list[$i][thumbnail][src] = $list[$i][thumbnail][path]."/".$list[$i][thumbnail][name];
// 이미지 비률 수정및 이미지 포멧방식 체크
list($r_width[$i]) = getimagesize($list[$i][thumbnail][src]);
}
break;
}
}
}
1번 2번 3번 4번 사진을 올리면 1번으로 섬네일 생성
그후 1번 2번을 수정으로 삭제하면
3번이 섬네일로 보여야 하는데 안되더군요 ㅠㅠ
1번 없으면 2번 없으면 3번 첨부가 있으면 섬네일로...하는 방법은 없을까요?
댓글 전체

if (file_exists($thumb)){
$img = "<img src='$thumb' width='$img_width' height='$img_height' style='border:3px solid #eee;' />";
}
위에 $thumb가 아니라 $file변수로 파일이 있는지 없는지 확인해야 할 것 같아요
for문에서 $file로 섬네일들을 담았네요