feat(submit): make video cover row icon-only with hover titles

Replace the video-pic/video/clear button labels with icon-only buttons
carrying title + aria-label (设置视频封面/视频/清除), center the glyphs
via flex to fix the upward icon shift, rename the media picker title to
为视频设置封面, and drop the unused setVideoCover i18n key. Contract
test updated to pin the new markup and string set.
This commit is contained in:
2026-09-06 10:10:12 +08:00
parent 51a591e2b9
commit daee4cd67f
4 changed files with 29 additions and 14 deletions
+2 -2
View File
@@ -522,7 +522,7 @@
type: 'image',
multiple: false,
allowExternal: false,
title: i18n.setVideoCoverTitle || '为视频设置首图封面',
title: i18n.setVideoCoverTitle || '为视频设置封面',
onSelect: function (cover) {
self.setFeatured('video', {
url: current.data.url,
@@ -554,7 +554,7 @@
type: 'image',
multiple: false,
allowExternal: false,
title: i18n.setVideoCoverTitle || '为视频设置首图封面',
title: i18n.setVideoCoverTitle || '为视频设置封面',
onSelect: function (cover) {
self.setFeatured('video', {
url: video.url,
+1 -2
View File
@@ -147,8 +147,7 @@ if (file_exists($js)) {
'fileTooLarge' => __('文件大小超过限制', 'aksrt'),
'lastSaved' => __('最后保存:', 'aksrt'),
'preview' => __('预览文章', 'aksrt'),
'setVideoCover' => __('设置视频首图封面', 'aksrt'),
'setVideoCoverTitle' => __('为视频设置首图封面', 'aksrt'),
'setVideoCoverTitle' => __('为视频设置封面', 'aksrt'),
'close' => __('关闭', 'aksrt'),
'insertImage' => __('插入图片', 'aksrt'),
'uploadImage' => __('上传图片', 'aksrt'),
+12 -6
View File
@@ -47,8 +47,10 @@ $can_video = !empty($ctx['can_cover_video']);
</button>
<?php endif; ?>
<?php if ($can_video) : ?>
<button type="button" class="but btn-video-pic" data-featured-action="video_pic">
<i class="fa fas fa-image"></i> <?php esc_html_e('设置视频首图封面', 'aksrt'); ?>
<button type="button" class="but btn-video-pic" data-featured-action="video_pic"
title="<?php esc_attr_e('设置视频封面', 'aksrt'); ?>"
aria-label="<?php esc_attr_e('设置视频封面', 'aksrt'); ?>">
<i class="fa fas fa-image"></i>
</button>
<?php endif; ?>
<?php if ($can_slide) : ?>
@@ -57,12 +59,16 @@ $can_video = !empty($ctx['can_cover_video']);
</button>
<?php endif; ?>
<?php if ($can_video) : ?>
<button type="button" class="but btn-video" data-featured-action="video">
<i class="fa fas fa-video"></i> <?php esc_html_e('视频', 'aksrt'); ?>
<button type="button" class="but btn-video" data-featured-action="video"
title="<?php esc_attr_e('视频', 'aksrt'); ?>"
aria-label="<?php esc_attr_e('视频', 'aksrt'); ?>">
<i class="fa fas fa-video"></i>
</button>
<?php endif; ?>
<button type="button" class="but c-red btn-delete" data-featured-action="close" <?php echo $type === '' ? 'hidden' : ''; ?>>
<i class="fa fas fa-trash-alt"></i> <?php esc_html_e('清除', 'aksrt'); ?>
<button type="button" class="but c-red btn-delete" data-featured-action="close" <?php echo $type === '' ? 'hidden' : ''; ?>
title="<?php esc_attr_e('清除', 'aksrt'); ?>"
aria-label="<?php esc_attr_e('清除', 'aksrt'); ?>">
<i class="fa fas fa-trash-alt"></i>
</button>
</div>
<input type="hidden" name="featured_data" value="<?php echo esc_attr(wp_json_encode(['type' => $type, 'data' => $data])); ?>" data-featured-json>
@@ -17,7 +17,12 @@ test('featured box renders a playable video preview and a video-cover button', (
assert.match(featured, /fa fas fa-play-circle/);
// The video-cover button is capability-gated like the video button.
assert.match(featured, /if \(\$can_video\) : \?>\s*\n\s*<button type="button" class="but btn-video-pic" data-featured-action="video_pic">/);
assert.match(featured, /if \(\$can_video\) : \?>\s*\n\s*<button type="button" class="but btn-video-pic" data-featured-action="video_pic"\s*\n\s*title="<\?php esc_attr_e\('设置视频封面', 'aksrt'\); \?>"/);
// The video row (video cover / video / clear) is icon-only with hover titles.
assert.match(featured, /btn-video" data-featured-action="video"\s*\n\s*title="<\?php esc_attr_e\('视频', 'aksrt'\); \?>"\s*\n\s*aria-label="<\?php esc_attr_e\('视频', 'aksrt'\); \?>">\s*\n\s*<i class="fa fas fa-video"><\/i>\s*\n\s*<\/button>/);
assert.match(featured, /btn-delete" data-featured-action="close"[\s\S]*?title="<\?php esc_attr_e\('清除', 'aksrt'\); \?>"/);
assert.doesNotMatch(featured, /首图|>视频<|>清除</);
// Dead capability attributes are gone.
assert.doesNotMatch(featured, /data-can-(image|slide|video)=/);
@@ -46,7 +51,9 @@ test('submit.css toggles the video-cover button like the reference theme', () =>
const css = read('assets/css/frontend/pages/submit.css');
assert.match(css, /\.featured-edit \.btns-full \.btn-video-pic \{\s*\n display: none;\s*\n\}/);
assert.match(css, /\.featured-loaded\.video \.btns-full \.btn-video-pic \{\s*\n display: inline-flex;\s*\n\}/);
assert.match(css, /\.featured-loaded\.video \.btns-full \.btn-video-pic \{\s*\n display: inline-flex;\s*\n align-items: center;\s*\n justify-content: center;\s*\n\}/);
assert.match(css, /\.featured-edit \.btns-full \.btn-video,\s*\n\.featured-edit \.btns-full \.btn-delete:not\(\[hidden\]\) \{\s*\n display: inline-flex;\s*\n align-items: center;\s*\n justify-content: center;\s*\n\}/);
assert.match(css, /\.featured-edit \.btns-full \.btn-video-pic > \.fa,[\s\S]*?\.featured-edit \.btns-full \.btn-delete > \.fa \{\s*\n margin-right: 0;\s*\n\}/);
assert.doesNotMatch(css, /featured-video-placeholder/);
});
@@ -71,8 +78,11 @@ test('i18n exposes the video-cover strings and dead keys are removed', () => {
const editorJs = read('assets/js/front-submit-editor.js');
const submitJs = read('assets/js/front-submit.js');
assert.match(page, /'setVideoCover' => __\('设置视频首图封面', 'aksrt'\)/);
assert.match(page, /'setVideoCoverTitle' => __\('为视频设置首图封面', 'aksrt'\)/);
assert.match(page, /'setVideoCoverTitle' => __\('为视频设置封面', 'aksrt'\)/);
// The unused setVideoCover key died with the visible button label it served.
assert.doesNotMatch(page, /'setVideoCover' =>/);
assert.doesNotMatch(page, /首图/);
assert.doesNotMatch(submitJs, /首图/);
assert.doesNotMatch(page, /'(pickImage|pickVideo|pickVideoCover|pickVideoResource|videoUrl)'/);
// data-video-name / mediaUrl stay: pinned by tinymce.css and the