mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
Allow customization of resize and conversion quality
This commit is contained in:
parent
2b67798cab
commit
b9208a682b
6 changed files with 26 additions and 5 deletions
|
|
@ -69,8 +69,10 @@ class fileAdminController extends file
|
|||
$config->max_image_width = intval(Context::get('max_image_width')) ?: '';
|
||||
$config->max_image_height = intval(Context::get('max_image_height')) ?: '';
|
||||
$config->max_image_size_action = Context::get('max_image_size_action') ?: '';
|
||||
$config->max_image_size_quality = max(50, min(100, intval(Context::get('max_image_size_quality'))));
|
||||
$config->image_autoconv['bmp2jpg'] = Context::get('image_autoconv_bmp2jpg') === 'Y' ? true : false;
|
||||
$config->image_autoconv['webp2jpg'] = Context::get('image_autoconv_webp2jpg') === 'Y' ? true : false;
|
||||
$config->image_autoconv_quality = max(50, min(100, intval(Context::get('image_autoconv_quality'))));
|
||||
|
||||
// Check maximum file size
|
||||
if (PHP_INT_SIZE < 8)
|
||||
|
|
|
|||
|
|
@ -1045,11 +1045,11 @@ class fileController extends file
|
|||
// Check image type
|
||||
if($config->image_autoconv['bmp2jpg'] && function_exists('imagebmp') && $image_type === 6)
|
||||
{
|
||||
$convert = array($image_width, $image_height, 'jpg');
|
||||
$convert = array($image_width, $image_height, 'jpg', $config->image_autoconv_quality ?: 75);
|
||||
}
|
||||
if($config->image_autoconv['webp2jpg'] && function_exists('imagewebp') && $image_type === 18)
|
||||
{
|
||||
$convert = array($image_width, $image_height, 'jpg');
|
||||
$convert = array($image_width, $image_height, 'jpg', $config->image_autoconv_quality ?: 75);
|
||||
}
|
||||
|
||||
// Check image size
|
||||
|
|
@ -1102,7 +1102,7 @@ class fileController extends file
|
|||
$resize_height = $config->max_image_height;
|
||||
}
|
||||
$target_type = in_array($image_type, array(6, 8, 18)) ? 'jpg' : $file_info['extension'];
|
||||
$convert = array(intval($resize_width), intval($resize_height), $target_type);
|
||||
$convert = array(intval($resize_width), intval($resize_height), $target_type, $config->max_image_size_quality ?: 75);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1110,8 +1110,7 @@ class fileController extends file
|
|||
// Convert image if necessary
|
||||
if ($convert)
|
||||
{
|
||||
$quality = 75;
|
||||
$result = FileHandler::createImageFile($file_info['tmp_name'], $file_info['tmp_name'] . '.conv', $convert[0], $convert[1], $convert[2], 'crop', $quality);
|
||||
$result = FileHandler::createImageFile($file_info['tmp_name'], $file_info['tmp_name'] . '.conv', $convert[0], $convert[1], $convert[2], 'crop', $convert[3]);
|
||||
if ($result)
|
||||
{
|
||||
$file_info['name'] = preg_replace('/\.' . preg_quote($file_info['extension'], '/') . '$/i', '.' . $convert[2], $file_info['name']);
|
||||
|
|
|
|||
|
|
@ -192,7 +192,9 @@ class fileModel extends file
|
|||
$config->max_image_width = $file_config->max_image_width;
|
||||
$config->max_image_height = $file_config->max_image_height;
|
||||
$config->max_image_size_action = $file_config->max_image_size_action;
|
||||
$config->max_image_size_quality = $file_config->max_image_size_quality;
|
||||
$config->image_autoconv = $file_config->image_autoconv;
|
||||
$config->image_autoconv_quality = $file_config->image_autoconv_quality;
|
||||
$config->download_grant = $file_config->download_grant;
|
||||
$config->allow_outlink = $file_config->allow_outlink;
|
||||
$config->allow_outlink_site = $file_config->allow_outlink_site;
|
||||
|
|
@ -210,7 +212,9 @@ class fileModel extends file
|
|||
if(!$config->max_image_width) $config->max_image_width = $file_module_config->max_image_width;
|
||||
if(!$config->max_image_height) $config->max_image_height = $file_module_config->max_image_height;
|
||||
if(!$config->max_image_size_action) $config->max_image_size_action = $file_module_config->max_image_size_action;
|
||||
if(!$config->max_image_size_quality) $config->max_image_size_quality = $file_module_config->max_image_size_quality;
|
||||
if(!$config->image_autoconv) $config->image_autoconv = $file_module_config->image_autoconv;
|
||||
if(!$config->image_autoconv_quality) $config->image_autoconv_quality = $file_module_config->image_autoconv_quality;
|
||||
|
||||
// Default setting if not exists
|
||||
if(!$config->allowed_filesize) $config->allowed_filesize = '2';
|
||||
|
|
@ -219,7 +223,9 @@ class fileModel extends file
|
|||
if(!$config->allow_outlink) $config->allow_outlink = 'Y';
|
||||
if(!$config->download_grant) $config->download_grant = array();
|
||||
if(!$config->inline_download_format) $config->inline_download_format = array();
|
||||
if(!$config->max_image_size_quality) $config->max_image_size_quality = 75;
|
||||
if(!$config->image_autoconv) $config->image_autoconv = array();
|
||||
if(!$config->image_autoconv_quality) $config->image_autoconv_quality = 75;
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ $lang->max_image_size = 'Maximum Image Size';
|
|||
$lang->max_image_size_action_nothing = 'If exceeded, do nothing';
|
||||
$lang->max_image_size_action_block = 'If exceeded, block upload';
|
||||
$lang->max_image_size_action_resize = 'If exceeded, resize automatically';
|
||||
$lang->image_resize_quality = 'Quality';
|
||||
$lang->image_autoconv = 'Auto-Convert Image';
|
||||
$lang->image_autoconv_bmp2jpg = 'BMP → JPG';
|
||||
$lang->image_autoconv_webp2jpg = 'WebP → JPG';
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ $lang->max_image_size = '이미지 크기 제한';
|
|||
$lang->max_image_size_action_nothing = '초과시 아무 것도 하지 않음';
|
||||
$lang->max_image_size_action_block = '초과시 업로드 금지';
|
||||
$lang->max_image_size_action_resize = '초과시 자동 크기 조정';
|
||||
$lang->image_resize_quality = '화질';
|
||||
$lang->image_autoconv = '이미지 자동 변환';
|
||||
$lang->image_autoconv_bmp2jpg = 'BMP → JPG';
|
||||
$lang->image_autoconv_webp2jpg = 'WebP → JPG';
|
||||
|
|
|
|||
|
|
@ -32,6 +32,12 @@
|
|||
<option value="block" selected="selected"|cond="$config->max_image_size_action == 'block'">{$lang->max_image_size_action_block}</option>
|
||||
<option value="resize" selected="selected"|cond="$config->max_image_size_action == 'resize'">{$lang->max_image_size_action_resize}</option>
|
||||
</select>
|
||||
<select name="max_image_size_quality" id="max_image_size_quality" style="width:100px;min-width:100px">
|
||||
{@ $config->max_image_size_quality = $config->max_image_size_quality ?: 75}
|
||||
<!--@for($q = 50; $q <= 100; $q += 5)-->
|
||||
<option value="{$q}" selected="selected"|cond="$config->max_image_size_quality == $q">{$lang->image_resize_quality} {$q}%</option>
|
||||
<!--@endfor-->
|
||||
</select>
|
||||
<p class="x_help-block">{$lang->about_max_image_size}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -46,6 +52,12 @@
|
|||
<input type="checkbox" name="image_autoconv_webp2jpg" id="image_autoconv_webp2jpg" value="Y" checked="checked"|cond="$config->image_autoconv['webp2jpg']" disabled="disabled"|cond="!function_exists('imagewebp')" />
|
||||
{$lang->image_autoconv_webp2jpg}
|
||||
</label>
|
||||
<select name="image_autoconv_quality" id="image_autoconv_quality" style="width:100px;min-width:100px">
|
||||
{@ $config->image_autoconv_quality = $config->image_autoconv_quality ?: 75}
|
||||
<!--@for($q = 50; $q <= 100; $q += 5)-->
|
||||
<option value="{$q}" selected="selected"|cond="$config->image_autoconv_quality == $q">{$lang->image_resize_quality} {$q}%</option>
|
||||
<!--@endfor-->
|
||||
</select>
|
||||
<p class="x_help-block">{$lang->about_image_autoconv}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue