feat(submit): add video cover picker with playable video preview
Featured video preview now renders a real DPlayer (video-url/video-pic) like the reference theme instead of a static image, so the cover video plays on the submit page. Top-right bar gains the video-cover button shown only when a video cover is loaded; backend honors pic_id and no longer deletes the thumbnail before cover validation. Drop dead i18n keys and data-can-* attributes.
This commit is contained in:
1 parent
d84d485ec7
commit
51a591e2b9
7 files changed
+188
-35
No files matched your search
@@ -498,23 +498,13 @@ body.aksrt-editor-media-open {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.featured-edit .featured-preview > img,
|
||||
.featured-edit .featured-video-placeholder {
|
||||
.featured-edit .featured-preview > img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
aspect-ratio: 2 / 1;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.featured-edit .featured-video-placeholder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
color: var(--muted-2-color, #999);
|
||||
}
|
||||
|
||||
.featured-edit .featured-type-badge {
|
||||
position: absolute;
|
||||
right: 12px;
|
||||
@@ -557,6 +547,14 @@ body.aksrt-editor-media-open {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.featured-edit .btns-full .btn-video-pic {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.featured-loaded.video .btns-full .btn-video-pic {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
.featured-loaded.image .btn-video,
|
||||
.featured-loaded.image .btn-slide,
|
||||
.featured-loaded.slide .btn-video,
|
||||
|
||||
@@ -400,6 +400,22 @@
|
||||
this.isDirty = true;
|
||||
},
|
||||
|
||||
destroyFeaturedPlayer: function (preview) {
|
||||
var old = qs('.new-dplayer', preview);
|
||||
if (!old || !window.jQuery) {
|
||||
return;
|
||||
}
|
||||
var dp = window.jQuery(old).data('dplayer');
|
||||
if (dp) {
|
||||
if (typeof dp.pause === 'function') {
|
||||
dp.pause();
|
||||
}
|
||||
if (typeof dp.destroy === 'function') {
|
||||
dp.destroy();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
renderFeaturedPreview: function () {
|
||||
var preview = qs('[data-featured-preview]');
|
||||
if (!preview) {
|
||||
@@ -424,12 +440,20 @@
|
||||
'" alt=""><span class="featured-type-badge"><i class="fa fas fa-image"></i></span>';
|
||||
} else if (t === 'video') {
|
||||
html =
|
||||
(d.pic
|
||||
? '<img src="' + escapeHtml(d.pic) + '" alt="">'
|
||||
: '<div class="featured-video-placeholder"><i class="fa fas fa-play"></i></div>') +
|
||||
'<div class="new-dplayer dplayer-scale-height" style="--scale-height:50%;" video-url="' +
|
||||
escapeHtml(d.url || '') +
|
||||
'" video-pic="' +
|
||||
escapeHtml(d.pic || '') +
|
||||
'"><div class="graphic" style="padding-bottom:50%;">' +
|
||||
'<div class="abs-center text-center"><i class="fa fas fa-play-circle fa-4x muted-3-color opacity5" aria-hidden="true"></i></div>' +
|
||||
'</div></div>' +
|
||||
'<span class="featured-type-badge"><i class="fa fas fa-video"></i></span>';
|
||||
}
|
||||
this.destroyFeaturedPlayer(preview);
|
||||
preview.innerHTML = html;
|
||||
if (t === 'video' && typeof window.auto_fun === 'function') {
|
||||
window.auto_fun();
|
||||
}
|
||||
var clearBtn = qs('[data-featured-action="close"]');
|
||||
if (clearBtn) {
|
||||
clearBtn.hidden = !t || t === 'close';
|
||||
@@ -489,6 +513,27 @@
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (act === 'video_pic') {
|
||||
var current = self.featured;
|
||||
if (current.type !== 'video' || !current.data || !current.data.url) {
|
||||
return;
|
||||
}
|
||||
self.openMediaPicker({
|
||||
type: 'image',
|
||||
multiple: false,
|
||||
allowExternal: false,
|
||||
title: i18n.setVideoCoverTitle || '为视频设置首图封面',
|
||||
onSelect: function (cover) {
|
||||
self.setFeatured('video', {
|
||||
url: current.data.url,
|
||||
pic: cover && cover.url ? cover.url : '',
|
||||
pic_id: cover ? (cover.attachment_id || cover.id || 0) : 0,
|
||||
id: current.data.id || 0,
|
||||
});
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (act === 'video') {
|
||||
self.openMediaPicker({
|
||||
type: 'video',
|
||||
@@ -509,7 +554,7 @@
|
||||
type: 'image',
|
||||
multiple: false,
|
||||
allowExternal: false,
|
||||
title: i18n.pickVideoCover || '选择视频封面(可选)',
|
||||
title: i18n.setVideoCoverTitle || '为视频设置首图封面',
|
||||
onSelect: function (cover) {
|
||||
self.setFeatured('video', {
|
||||
url: video.url,
|
||||
|
||||
Reference in new issue
Block a user