update thumbnail.lib.php

This commit is contained in:
Amberstone 2024-10-21 11:30:05 +09:00
parent 1a5ccfe03b
commit 8f2a411c7a
Signed by: amber
GPG key ID: 094B0E55F98D8BF1

View file

@ -5,7 +5,7 @@ if (!defined('_GNUBOARD_'))
@ini_set('memory_limit', '-1'); @ini_set('memory_limit', '-1');
// 게시글리스트 썸네일 생성 // 게시글리스트 썸네일 생성
function get_list_thumbnail($bo_table, $wr_id, $thumb_width, $thumb_height, $is_create = false, $is_crop = false, $crop_mode = 'center', $is_sharpen = false, $um_value = '80/0.5/3') function get_list_thumbnail($bo_table, $wr_id, $thumb_width, $thumb_height, $is_create = false, $is_crop = false, $crop_mode = 'center', $is_sharpen = false, $um_value = '80/0.5/3', $distance = '0')
{ {
global $g5, $config; global $g5, $config;
$filename = $alt = $data_path = ''; $filename = $alt = $data_path = '';
@ -66,7 +66,7 @@ function get_list_thumbnail($bo_table, $wr_id, $thumb_width, $thumb_height, $is_
return $thumbnail_info; return $thumbnail_info;
} }
$tname = thumbnail($filename, $filepath, $filepath, $thumb_width, $thumb_height, $is_create, $is_crop, $crop_mode, $is_sharpen, $um_value); $tname = thumbnail($filename, $filepath, $filepath, $thumb_width, $thumb_height, $is_create, $is_crop, $crop_mode, $is_sharpen, $um_value, $distance);
if ($tname) { if ($tname) {
if ($edt) { if ($edt) {
@ -229,7 +229,7 @@ function get_view_thumbnail($contents, $thumb_width = 0)
return run_replace('get_view_thumbnail', $contents); return run_replace('get_view_thumbnail', $contents);
} }
function thumbnail($filename, $source_path, $target_path, $thumb_width, $thumb_height, $is_create, $is_crop = false, $crop_mode = 'center', $is_sharpen = false, $um_value = '80/0.5/3') function thumbnail($filename, $source_path, $target_path, $thumb_width, $thumb_height, $is_create, $is_crop = false, $crop_mode = 'center', $is_sharpen = false, $um_value = '80/0.5/3', $distance = '0')
{ {
global $g5; global $g5;
@ -384,6 +384,14 @@ function thumbnail($filename, $source_path, $target_path, $thumb_width, $thumb_h
$src_x = round(($size[0] - $src_w) / 2); $src_x = round(($size[0] - $src_w) / 2);
} }
break; break;
case 'custom':
if ($size[1] / $size[0] >= $ratio) {
$src_h = round($src_w * $ratio);
$src_y = $distance;
} else {
$src_w = round($size[1] / $ratio);
}
break;
default: default:
if ($size[1] / $size[0] >= $ratio) { if ($size[1] / $size[0] >= $ratio) {
$src_h = round($src_w * $ratio); $src_h = round($src_w * $ratio);