mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
Support more options for image autoconv
This commit is contained in:
parent
7f8f303787
commit
9f75788491
5 changed files with 46 additions and 48 deletions
|
|
@ -72,12 +72,18 @@ class FileAdminController extends File
|
|||
$config->allowed_filetypes = Context::get('allowed_filetypes');
|
||||
|
||||
// Image settings
|
||||
$config->image_autoconv['bmp2jpg'] = Context::get('image_autoconv_bmp2jpg') === 'Y' ? true : false;
|
||||
$config->image_autoconv['png2jpg'] = Context::get('image_autoconv_png2jpg') === 'Y' ? true : false;
|
||||
$config->image_autoconv['webp2jpg'] = Context::get('image_autoconv_webp2jpg') === 'Y' ? true : false;
|
||||
$config->image_autoconv['avif2jpg'] = Context::get('image_autoconv_avif2jpg') === 'Y' ? true : false;
|
||||
$config->image_autoconv['heic2jpg'] = Context::get('image_autoconv_heic2jpg') === 'Y' ? true : false;
|
||||
$config->image_autoconv['gif2mp4'] = Context::get('image_autoconv_gif2mp4') === 'Y' ? true : false;
|
||||
$config->image_autoconv = [];
|
||||
foreach (Context::get('image_autoconv') ?: [] as $source_type => $target_type)
|
||||
{
|
||||
if (in_array($target_type, ['Y', 'N']))
|
||||
{
|
||||
$config->image_autoconv[$source_type] = tobool($target_type);
|
||||
}
|
||||
elseif (in_array($target_type, ['', 'jpg', 'png', 'webp']))
|
||||
{
|
||||
$config->image_autoconv[$source_type] = $target_type;
|
||||
}
|
||||
}
|
||||
$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') ?: '';
|
||||
|
|
|
|||
|
|
@ -1176,23 +1176,11 @@ class FileController extends File
|
|||
{
|
||||
$adjusted['type'] = 'mp4';
|
||||
}
|
||||
elseif ($config->image_autoconv['png2jpg'] && $image_info['type'] === 'png' && function_exists('imagepng'))
|
||||
elseif (!empty($config->image_autoconv[$image_info['type']]))
|
||||
{
|
||||
$adjusted['type'] = 'jpg';
|
||||
$adjusted['type'] = $config->image_autoconv[$image_info['type']];
|
||||
}
|
||||
elseif ($config->image_autoconv['webp2jpg'] && $image_info['type'] === 'webp' && function_exists('imagewebp'))
|
||||
{
|
||||
$adjusted['type'] = 'jpg';
|
||||
}
|
||||
elseif ($config->image_autoconv['bmp2jpg'] && $image_info['type'] === 'bmp' && function_exists('imagebmp'))
|
||||
{
|
||||
$adjusted['type'] = 'jpg';
|
||||
}
|
||||
elseif ($config->image_autoconv['avif2jpg'] && $image_info['type'] === 'avif')
|
||||
{
|
||||
$adjusted['type'] = 'jpg';
|
||||
}
|
||||
elseif ($config->image_autoconv['heic2jpg'] && $image_info['type'] === 'heic')
|
||||
elseif (!empty($config->image_autoconv[$image_info['type'] . '2jpg']))
|
||||
{
|
||||
$adjusted['type'] = 'jpg';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,11 +91,6 @@ $lang->use_video_default_file_config = '동영상 파일 기본 설정 사용';
|
|||
$lang->about_use_video_default_file_config = '파일 모듈의 동영상 파일 기본 설정을 따릅니다.';
|
||||
$lang->image_autoconv = '이미지 자동 변환';
|
||||
$lang->about_image_autoconv = '업로드된 이미지의 타입을 변환합니다. 다양한 환경에서 호환되지 않거나, 용량을 낭비하는 이미지를 처리할 수 있습니다.';
|
||||
$lang->image_autoconv_bmp2jpg = 'BMP → JPG';
|
||||
$lang->image_autoconv_png2jpg = 'PNG → JPG';
|
||||
$lang->image_autoconv_webp2jpg = 'WebP → JPG';
|
||||
$lang->image_autoconv_avif2jpg = 'AVIF → JPG';
|
||||
$lang->image_autoconv_heic2jpg = 'HEIC → JPG';
|
||||
$lang->max_image_size = '이미지 크기 제한';
|
||||
$lang->about_max_image_size = '업로드된 이미지의 크기를 제한하거나 조정합니다. 파일 용량과는 직접적인 관계가 없으니 참고하세요.';
|
||||
$lang->max_image_size_action_nothing = '초과시 아무 것도 하지 않음';
|
||||
|
|
|
|||
|
|
@ -4,6 +4,21 @@
|
|||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
.image_autoconv_types {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.image_autoconv_types:last-of-type {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.image_autoconv_types .x_inline {
|
||||
display: inline-block;
|
||||
min-width: 40px;
|
||||
}
|
||||
.image_autoconv_types select {
|
||||
min-width: 0 !important;
|
||||
margin-left: 16px;
|
||||
}
|
||||
|
||||
.x_help-block .preset_size {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,26 +35,20 @@
|
|||
<div class="x_control-group">
|
||||
<label class="x_control-label">{$lang->image_autoconv}</label>
|
||||
<div class="x_controls">
|
||||
<label for="image_autoconv_bmp2jpg">
|
||||
<input type="checkbox" name="image_autoconv_bmp2jpg" id="image_autoconv_bmp2jpg" value="Y" checked="checked"|cond="$config->image_autoconv['bmp2jpg']" disabled="disabled"|cond="!function_exists('imagebmp')" />
|
||||
{$lang->image_autoconv_bmp2jpg}
|
||||
</label>
|
||||
<label for="image_autoconv_png2jpg">
|
||||
<input type="checkbox" name="image_autoconv_png2jpg" id="image_autoconv_png2jpg" value="Y" checked="checked"|cond="$config->image_autoconv['png2jpg']" disabled="disabled"|cond="!function_exists('imagepng')" />
|
||||
{$lang->image_autoconv_png2jpg}
|
||||
</label>
|
||||
<label for="image_autoconv_webp2jpg">
|
||||
<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>
|
||||
<label for="image_autoconv_avif2jpg">
|
||||
<input type="checkbox" name="image_autoconv_avif2jpg" id="image_autoconv_avif2jpg" value="Y" checked="checked"|cond="$config->image_autoconv['avif2jpg']" disabled="disabled"|cond="!$is_magick" />
|
||||
{$lang->image_autoconv_avif2jpg}
|
||||
</label>
|
||||
<label for="image_autoconv_heic2jpg">
|
||||
<input type="checkbox" name="image_autoconv_heic2jpg" id="image_autoconv_heic2jpg" value="Y" checked="checked"|cond="$config->image_autoconv['heic2jpg']" disabled="disabled"|cond="!$is_magick" />
|
||||
{$lang->image_autoconv_heic2jpg}
|
||||
</label>
|
||||
{@ $source_types = ['bmp', 'jpg', 'png', 'webp', 'avif', 'heic']}
|
||||
<!--@foreach($source_types as $source_type)-->
|
||||
<div class="image_autoconv_types">
|
||||
<label for="image_autoconv_{$source_type}" class="x_inline">
|
||||
{strtoupper($source_type)}
|
||||
</label> →
|
||||
<select name="image_autoconv[{$source_type}]" id="image_autoconv_{$source_type}" disabled="disabled"|cond="!$is_magick && in_array($source_type, ['avif', 'heic'])">
|
||||
<option value=""></option>
|
||||
<option value="jpg" selected="selected"|cond="($config->image_autoconv[$source_type] ?? '') === 'jpg' || !empty($config->image_autoconv[$source_type . '2jpg'])">JPG</option>
|
||||
<option value="png" selected="selected"|cond="($config->image_autoconv[$source_type] ?? '') === 'png'">PNG</option>
|
||||
<option value="webp" selected="selected"|cond="($config->image_autoconv[$source_type] ?? '') === 'webp'">WebP</option>
|
||||
</select>
|
||||
</div>
|
||||
<!--@endforeach-->
|
||||
<p class="x_help-block">
|
||||
{$lang->about_image_autoconv}<br />
|
||||
{$lang->msg_need_magick}
|
||||
|
|
@ -135,11 +129,11 @@
|
|||
<label class="x_control-label">{$lang->image_autoconv_gif2mp4}</label>
|
||||
<div class="x_controls">
|
||||
<label for="image_autoconv_gif2mp4_Y" class="x_inline">
|
||||
<input type="radio" name="image_autoconv_gif2mp4" id="image_autoconv_gif2mp4_Y" value="Y" checked="checked"|cond="$config->image_autoconv['gif2mp4'] === true" disabled="disabled"|cond="!$is_ffmpeg" />
|
||||
<input type="radio" name="image_autoconv[gif2mp4]" id="image_autoconv_gif2mp4_Y" value="Y" checked="checked"|cond="$config->image_autoconv['gif2mp4'] === true" disabled="disabled"|cond="!$is_ffmpeg" />
|
||||
{$lang->cmd_yes}
|
||||
</label>
|
||||
<label for="image_autoconv_gif2mp4_N" class="x_inline">
|
||||
<input type="radio" name="image_autoconv_gif2mp4" id="image_autoconv_gif2mp4_N" value="N" checked="checked"|cond="$config->image_autoconv['gif2mp4'] !== true" disabled="disabled"|cond="!$is_ffmpeg" />
|
||||
<input type="radio" name="image_autoconv[gif2mp4]" id="image_autoconv_gif2mp4_N" value="N" checked="checked"|cond="$config->image_autoconv['gif2mp4'] !== true" disabled="disabled"|cond="!$is_ffmpeg" />
|
||||
{$lang->cmd_no}
|
||||
</label>
|
||||
<p class="x_help-block">{$lang->about_image_autoconv_gif2mp4}</p>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue