Make profile image force aspect ratio setting confugurable

This commit is contained in:
Kijin Sung 2022-01-28 16:14:44 +09:00
parent 6e0b4ab688
commit 8d67f80283
5 changed files with 28 additions and 5 deletions

View file

@ -303,6 +303,7 @@ $lang->cmd_optional = 'Optional';
$lang->cmd_disabled = 'Disabled';
$lang->cmd_image_max_width = 'Max Width';
$lang->cmd_image_max_height = 'Max Height';
$lang->cmd_image_force_ratio = 'Fixed Aspect Ratio';
$lang->cmd_input_extend_form = 'Add Signup Form Field';
$lang->about_multi_type = 'Enter the value of multi-or single-item selection.(separated by line breaks)';
$lang->msg_delete_extend_form = 'Delete the selected item.';

View file

@ -317,6 +317,7 @@ $lang->cmd_optional = '선택';
$lang->cmd_disabled = '사용 안 함';
$lang->cmd_image_max_width = '너비 제한';
$lang->cmd_image_max_height = '높이 제한';
$lang->cmd_image_force_ratio = '가로세로 비율 고정';
$lang->cmd_input_extend_form = '회원가입 추가 항목 생성';
$lang->about_multi_type = '다중 또는 단일 항목의 선택 값을 입력하세요.(줄 바꿈으로 구분)';
$lang->msg_delete_extend_form = '선택한 항목을 삭제합니다.';

View file

@ -371,7 +371,7 @@ class memberAdminController extends member
'emailhost_check',
'special_phone_number', 'special_phone_code', 'max_auth_sms_count', 'max_auth_sms_count_time', 'redirect_url',
'phone_number_default_country', 'phone_number_hide_country', 'phone_number_allow_duplicate', 'phone_number_verify_by_sms',
'profile_image_max_width', 'profile_image_max_height', 'profile_image_max_filesize',
'profile_image_max_width', 'profile_image_max_height', 'profile_image_max_filesize', 'profile_image_force_ratio',
'image_name_max_width', 'image_name_max_height', 'image_name_max_filesize',
'image_mark_max_width', 'image_mark_max_height', 'image_mark_max_filesize',
'signature_editor_skin', 'sel_editor_colorset', 'signature_html', 'signature_html_retroact', 'member_allow_fileupload'
@ -469,6 +469,7 @@ class memberAdminController extends member
$signupItem->max_width = $all_args->{$key.'_max_width'};
$signupItem->max_height = $all_args->{$key.'_max_height'};
$signupItem->max_filesize = $all_args->{$key.'_max_filesize'};
$signupItem->force_ratio = $all_args->{$key.'_force_ratio'} === 'N' ? 'N' : 'Y';
}
// set extends form

View file

@ -1431,7 +1431,7 @@ class memberController extends member
* Insert a profile image
*
* @param int $member_srl
* @param object $target_file
* @param string $target_file
*
* @return void
*/
@ -1458,14 +1458,27 @@ class memberController extends member
}
$target_path = sprintf('files/member_extra_info/profile_image/%s', getNumberingPath($member_srl));
$target_filename = sprintf('%s%d.%s', $target_path, $member_srl, $ext);
FileHandler::makeDir($target_path);
$target_filename = sprintf('%s%d.%s', $target_path, $member_srl, $ext);
// Convert if the image size is larger than a given size
if($width > $max_width || $height > $max_height)
if ($width > $max_width || $height > $max_height)
{
$resize = true;
}
elseif ($config->profile_image_force_ratio !== 'N' && ($width / $height !== $max_width / $max_height))
{
$resize = true;
}
else
{
$resize = false;
}
if ($resize)
{
$temp_filename = sprintf('files/cache/tmp/profile_image_%d.%s', $member_srl, $ext);
FileHandler::createImageFile($target_file, $temp_filename, $max_width, $max_height, $ext);
FileHandler::createImageFile($target_file, $temp_filename, $max_width, $max_height, $ext, 'fill', 75);
// 파일 용량 제한
FileHandler::clearStatCache($temp_filename);

View file

@ -152,6 +152,13 @@
<p class="x_help-block">
<label class="x_inline" for="{$item->name}_max_filesize">{$lang->allowed_filesize}</label> <input type="number" min="1" name="{$item->name}_max_filesize" id="{$item->name}_max_filesize" value="{$item->max_filesize}" /> KB
</p>
<!--@if($item->name === 'profile_image')-->
<p class="x_help-block">
<label class="x_inline">{$lang->cmd_image_force_ratio}</label>
<label class="x_inline"><input type="radio" name="profile_image_force_ratio" value="Y" checked="checked"|cond="$config->profile_image_force_ratio !== 'N'" /> {$lang->cmd_yes}</label>
<label class="x_inline"><input type="radio" name="profile_image_force_ratio" value="N" checked="checked"|cond="$config->profile_image_force_ratio === 'N'" /> {$lang->cmd_no}</label>
</p>
<!--@endif-->
</div>
<div cond="$item->name == 'phone_number'" class="_subItem" style="display:none"|cond="!$item->isUse">