원본 비율 유지 썸네일 생성 (리사이즈) 정보
원본 비율 유지 썸네일 생성 (리사이즈)본문
list.skin.php
해당 게시판 환경설정은 무시됨
$tw_max = 150; //썸네일 가로 최대 사이즈
$th_max = 150; //썸네일 세로 최대 사이즈
$data_path = G5_URL."/data/file/".$bo_table;
$file_list = urlencode($list[$i][file][0][file]);
if (preg_match("/\.(gif|jpg|png)$/i", $file_list)) {
//$file_ori = $data_path ."/".$file_list; //원본 이미지
$t_w = $list[$i][file][0][image_width]; //원본파일 사이즈
$t_h = $list[$i][file][0][image_height];
if ($t_w < $tw_max){
if ($t_h > $th_max){
$h = $th_max ;
$w = ceil( $t_w * ( $th_max / $t_h ) );
} else {
$h = $t_h;
$w = $t_w;
}
}else{
if (( $t_h / $t_w ) > ($th_max / $tw_max)){
$h = $th_max ;
$w = ceil( $t_w * ( $th_max / $t_h ) );
}else{
$w = $tw_max ;
$h = ceil( $t_h * ( $tw_max / $t_w ) );
}
}
$w = (int)$w; //소수점이하 버림
$h = (int)$h;
$thumb = get_list_thumbnail($board['bo_table'], $list[$i]['wr_id'], $w, $h);
// $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="'.$w.'" height="'.$h.'">';
} else {
$img_content = '<span style="width:'.$w.'px;height:'.$h.'px">no image</span>';
}
echo $img_content;
}
해당 게시판 환경설정은 무시됨
$tw_max = 150; //썸네일 가로 최대 사이즈
$th_max = 150; //썸네일 세로 최대 사이즈
$data_path = G5_URL."/data/file/".$bo_table;
$file_list = urlencode($list[$i][file][0][file]);
if (preg_match("/\.(gif|jpg|png)$/i", $file_list)) {
//$file_ori = $data_path ."/".$file_list; //원본 이미지
$t_w = $list[$i][file][0][image_width]; //원본파일 사이즈
$t_h = $list[$i][file][0][image_height];
if ($t_w < $tw_max){
if ($t_h > $th_max){
$h = $th_max ;
$w = ceil( $t_w * ( $th_max / $t_h ) );
} else {
$h = $t_h;
$w = $t_w;
}
}else{
if (( $t_h / $t_w ) > ($th_max / $tw_max)){
$h = $th_max ;
$w = ceil( $t_w * ( $th_max / $t_h ) );
}else{
$w = $tw_max ;
$h = ceil( $t_h * ( $tw_max / $t_w ) );
}
}
$w = (int)$w; //소수점이하 버림
$h = (int)$h;
$thumb = get_list_thumbnail($board['bo_table'], $list[$i]['wr_id'], $w, $h);
// $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="'.$w.'" height="'.$h.'">';
} else {
$img_content = '<span style="width:'.$w.'px;height:'.$h.'px">no image</span>';
}
echo $img_content;
}
추천
2
2
댓글 6개

썸네일 생성후 파일 위치등은 특별히 지정이 없나요?
$t_w 값은 어떻게 가져와야할까요.
수정했습니다.
실수로 원본 사이즈를 안가져 왔네요.
실수로 원본 사이즈를 안가져 왔네요.
혹시 업로드할때 바로 리사이즈 적용하는 방법은 없을까요?
필요했던건데 테스트 해보겠습니다
감사합니다.
감사합니다.
잘 사용했습니다.