fix(user): move avatar upload to hover overlay
This commit is contained in:
@@ -380,20 +380,15 @@ if (!function_exists('aksrt_user_center_avatar_upload_config')) {
|
||||
'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'),
|
||||
'errorText' => __('头像上传失败', 'aksrt'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,13 @@ extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_
|
||||
<div class="uc-header__content">
|
||||
<div class="uc-header__avatar">
|
||||
<?php echo aksrt_get_avatar_html($user_id, 120, ['id' => 'aksrt-user-avatar-image', 'alt' => $target_user->display_name, 'loading' => 'eager']); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<?php if ($show_avatar_edit) : ?>
|
||||
<button type="button" id="aksrt-upload-avatar-btn" class="uc-header__avatar-upload" title="<?php esc_attr_e('更换头像', 'aksrt'); ?>" aria-label="<?php esc_attr_e('更换头像', 'aksrt'); ?>">
|
||||
<i class="fas fa-camera" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e('更换头像', 'aksrt'); ?></span>
|
||||
</button>
|
||||
<input type="file" id="aksrt-avatar-file-input" accept="image/jpeg,image/png,image/webp,image/gif" hidden>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="uc-header__info">
|
||||
<h1 class="uc-header__name">
|
||||
@@ -90,15 +97,6 @@ extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($show_avatar_edit) : ?>
|
||||
<button type="button" id="aksrt-upload-avatar-btn" class="btn-ghost btn-sm">
|
||||
<i class="fas fa-camera" aria-hidden="true"></i> <span><?php esc_html_e('更换头像', 'aksrt'); ?></span>
|
||||
</button>
|
||||
<input type="file" id="aksrt-avatar-file-input" accept="image/jpeg,image/png,image/webp,image/gif" hidden>
|
||||
<button type="button" id="aksrt-remove-avatar-btn" class="btn-ghost btn-sm"<?php echo get_user_meta($user_id, 'aksrt_avatar_attachment_id', true) ? '' : ' hidden'; ?>>
|
||||
<i class="fas fa-undo" aria-hidden="true"></i> <span><?php esc_html_e('恢复默认头像', 'aksrt'); ?></span>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<a href="<?php echo esc_url(aksrt_get_user_home_url()); ?>" class="btn-ghost btn-sm">
|
||||
<i class="fas fa-map-marker-alt" aria-hidden="true"></i> <?php esc_html_e('我的主页', 'aksrt'); ?>
|
||||
</a>
|
||||
|
||||
Reference in New Issue
Block a user