feat(user): add local avatar management flow
This commit is contained in:
1 parent
1b4ba8938a
commit
e94437ef60
20 files changed
+289
-186
No files matched your search
@@ -373,20 +373,27 @@ if (!function_exists('aksrt_user_center_avatar_upload_config')) {
|
||||
if (!$enabled) {
|
||||
return [];
|
||||
}
|
||||
$settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_all() : [];
|
||||
$max_size = max(1, min(10, (int) ($settings['avatar_max_size'] ?? 2))) * MB_IN_BYTES;
|
||||
return [
|
||||
'enabled' => true,
|
||||
'restUrl' => rest_url('aksrt/v1/user/avatar'),
|
||||
'restNonce' => wp_create_nonce('wp_rest'),
|
||||
'buttonId' => 'aksrt-upload-avatar-btn',
|
||||
'inputId' => 'aksrt-avatar-file-input',
|
||||
'imageId' => 'aksrt-user-avatar-image',
|
||||
'fieldName' => 'avatar',
|
||||
'maxSize' => 2 * MB_IN_BYTES,
|
||||
'idleText' => __('更换头像', 'aksrt'),
|
||||
'loadingText' => __('上传中…', 'aksrt'),
|
||||
'tooLargeText' => __('图片大小不能超过 2MB', 'aksrt'),
|
||||
'successText' => __('头像已更新', 'aksrt'),
|
||||
'errorText' => __('头像上传失败', 'aksrt'),
|
||||
'enabled' => true,
|
||||
'restUrl' => rest_url('aksrt/v1/user/avatar'),
|
||||
'restNonce' => wp_create_nonce('wp_rest'),
|
||||
'buttonId' => 'aksrt-upload-avatar-btn',
|
||||
'removeButtonId' => 'aksrt-remove-avatar-btn',
|
||||
'inputId' => 'aksrt-avatar-file-input',
|
||||
'imageId' => 'aksrt-user-avatar-image',
|
||||
'fieldName' => 'avatar',
|
||||
'maxSize' => $max_size,
|
||||
'idleText' => __('更换头像', 'aksrt'),
|
||||
'loadingText' => __('上传中…', 'aksrt'),
|
||||
'removeText' => __('恢复默认头像', 'aksrt'),
|
||||
'removingText' => __('恢复中…', 'aksrt'),
|
||||
'confirmRemoveText' => __('确定恢复为默认头像?当前上传的头像文件将被删除。', 'aksrt'),
|
||||
'tooLargeText' => sprintf(__('图片大小不能超过 %dMB', 'aksrt'), (int) ($max_size / MB_IN_BYTES)),
|
||||
'successText' => __('头像已更新', 'aksrt'),
|
||||
'removeSuccessText' => __('已恢复默认头像', 'aksrt'),
|
||||
'errorText' => __('头像操作失败', 'aksrt'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user