Compare commits
1 Commits
main
...
thumbnail-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a875df7c49 |
@ -937,8 +937,6 @@ export default Component.extend(
|
|||||||
// Short upload urls need resolution
|
// Short upload urls need resolution
|
||||||
resolveAllShortUrls(ajax, this.siteSettings, preview);
|
resolveAllShortUrls(ajax, this.siteSettings, preview);
|
||||||
|
|
||||||
this._generateVideoThumbnail();
|
|
||||||
|
|
||||||
preview.addEventListener("click", this._handleImageScaleButtonClick);
|
preview.addEventListener("click", this._handleImageScaleButtonClick);
|
||||||
this._registerImageAltTextButtonClick(preview);
|
this._registerImageAltTextButtonClick(preview);
|
||||||
|
|
||||||
|
|||||||
@ -325,6 +325,11 @@ export default Mixin.create(ExtendableUploader, UppyS3Multipart, {
|
|||||||
|
|
||||||
cacheShortUploadUrl(upload.short_url, upload);
|
cacheShortUploadUrl(upload.short_url, upload);
|
||||||
|
|
||||||
|
// video/mp4, video/webm, video/quicktime, etc.
|
||||||
|
if (file.type.split("/")[0] === "video") {
|
||||||
|
this._generateVideoThumbnail(file, upload.url);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.useUploadPlaceholders) {
|
if (this.useUploadPlaceholders) {
|
||||||
this.appEvents.trigger(
|
this.appEvents.trigger(
|
||||||
`${this.composerEventPrefix}:replace-text`,
|
`${this.composerEventPrefix}:replace-text`,
|
||||||
|
|||||||
@ -17,30 +17,12 @@ export default Mixin.create(ExtendableUploader, UppyS3Multipart, {
|
|||||||
useUploadPlaceholders: true,
|
useUploadPlaceholders: true,
|
||||||
|
|
||||||
@bind
|
@bind
|
||||||
_generateVideoThumbnail() {
|
_generateVideoThumbnail(videoFile, uploadUrl) {
|
||||||
if (!this.siteSettings.enable_diffhtml_preview) {
|
let video = document.createElement("video");
|
||||||
return;
|
video.src = URL.createObjectURL(videoFile.data);
|
||||||
}
|
|
||||||
|
|
||||||
let videos = document.getElementsByClassName("video-container");
|
let videoSha1 = uploadUrl
|
||||||
if (!videos) {
|
.substring(uploadUrl.lastIndexOf("/") + 1)
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only generate a topic thumbnail for the first video
|
|
||||||
let video_container = videos[0];
|
|
||||||
if (!video_container) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let video = video_container.querySelector("video:first-of-type");
|
|
||||||
if (!video) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let video_src = video.getElementsByTagName("source")[0].src;
|
|
||||||
let video_sha1 = video_src
|
|
||||||
.substring(video_src.lastIndexOf("/") + 1)
|
|
||||||
.split(".")[0];
|
.split(".")[0];
|
||||||
|
|
||||||
// Wait for the video element to load, otherwise the canvas will be empty
|
// Wait for the video element to load, otherwise the canvas will be empty
|
||||||
@ -58,10 +40,10 @@ export default Mixin.create(ExtendableUploader, UppyS3Multipart, {
|
|||||||
// upload video thumbnail
|
// upload video thumbnail
|
||||||
canvas.toBlob((blob) => {
|
canvas.toBlob((blob) => {
|
||||||
this._uppyInstance = new Uppy({
|
this._uppyInstance = new Uppy({
|
||||||
id: `screenshot-placeholder`,
|
id: "video-thumbnail",
|
||||||
meta: {
|
meta: {
|
||||||
upload_type: `thumbnail`,
|
upload_type: `thumbnail`,
|
||||||
video_sha1,
|
videoSha1,
|
||||||
},
|
},
|
||||||
autoProceed: true,
|
autoProceed: true,
|
||||||
});
|
});
|
||||||
@ -99,7 +81,7 @@ export default Mixin.create(ExtendableUploader, UppyS3Multipart, {
|
|||||||
try {
|
try {
|
||||||
this._uppyInstance.addFile({
|
this._uppyInstance.addFile({
|
||||||
source: `${this.id} thumbnail`,
|
source: `${this.id} thumbnail`,
|
||||||
name: video_sha1,
|
name: `${videoSha1}`,
|
||||||
type: blob.type,
|
type: blob.type,
|
||||||
data: blob,
|
data: blob,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user