Fix #1707 support thumbnail height value of 'auto' in any type

This commit is contained in:
Kijin Sung 2021-06-19 23:11:59 +09:00
parent 856f2af743
commit 633bc340e7
3 changed files with 16 additions and 10 deletions

View file

@ -543,7 +543,13 @@ class FileHandler
{
$target_type = 'jpg';
}
// Automatically set resize_height if it is 'auto'
if ($resize_height === 'auto')
{
$resize_height = round($resize_width / ($width / $height));
}
// create temporary image having original type
if ($type === 'gif' && function_exists('imagecreatefromgif'))
{

View file

@ -698,7 +698,7 @@ class commentItem extends BaseObject
}
// If signiture height setting is omitted, create a square
if(!$height)
if(!$height || (!ctype_digit($height) && $height !== 'auto'))
{
$height = $width;
}
@ -707,7 +707,7 @@ class commentItem extends BaseObject
$thumbnail_path = sprintf('files/thumbnails/%s', getNumberingPath($this->comment_srl, 3));
$thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type);
$thumbnail_lockfile = sprintf('%s%dx%d.%s.lock', $thumbnail_path, $width, $height, $thumbnail_type);
$thumbnail_url = Context::getRequestUri() . $thumbnail_file;
$thumbnail_url = RX_BASEURL . $thumbnail_file;
$thumbnail_file = RX_BASEDIR . $thumbnail_file;
// return false if a size of existing thumbnail file is 0. otherwise return the file path
@ -762,7 +762,7 @@ class commentItem extends BaseObject
if($file->cover_image === 'Y' && file_exists($file->uploaded_filename))
{
$source_file = $file->uploaded_filename;
$source_file = FileHandler::getRealPath($file->uploaded_filename);
break;
}
@ -779,7 +779,7 @@ class commentItem extends BaseObject
if(!$source_file && $first_image)
{
$source_file = $first_image;
$source_file = FileHandler::getRealPath($first_image);
}
}

View file

@ -1082,7 +1082,7 @@ class documentItem extends BaseObject
}
// If not specify its height, create a square
if(!$height)
if(!$height || (!ctype_digit($height) && $height !== 'auto'))
{
$height = $width;
}
@ -1091,7 +1091,7 @@ class documentItem extends BaseObject
$thumbnail_path = sprintf('files/thumbnails/%s',getNumberingPath($this->document_srl, 3));
$thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type);
$thumbnail_lockfile = sprintf('%s%dx%d.%s.lock', $thumbnail_path, $width, $height, $thumbnail_type);
$thumbnail_url = Context::getRequestUri().$thumbnail_file;
$thumbnail_url = RX_BASEURL . $thumbnail_file;
$thumbnail_file = RX_BASEDIR . $thumbnail_file;
// Return false if thumbnail file exists and its size is 0. Otherwise, return its path
@ -1166,7 +1166,7 @@ class documentItem extends BaseObject
}
if($file->cover_image === 'Y')
{
$source_file = $file->uploaded_filename;
$source_file = FileHandler::getRealPath($file->uploaded_filename);
break;
}
if(!$first_image)
@ -1176,7 +1176,7 @@ class documentItem extends BaseObject
}
if(!$source_file && $first_image)
{
$source_file = $first_image;
$source_file = FileHandler::getRealPath($first_image);
}
}
@ -1229,7 +1229,7 @@ class documentItem extends BaseObject
}
}
}
if($source_file)
{
$output_file = FileHandler::createImageFile($source_file, $thumbnail_file, $trigger_obj->width, $trigger_obj->height, $trigger_obj->image_type, $trigger_obj->type, $trigger_obj->quality);