From 3d22afbf0d9d79665c649f9f02dda23e1bb54511 Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Sun, 10 Nov 2024 14:00:41 +1100 Subject: [PATCH] thrimbletrimmer: Load uploaded template in crop tool when type = ONEOFF --- thrimbletrimmer/scripts/edit.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/thrimbletrimmer/scripts/edit.js b/thrimbletrimmer/scripts/edit.js index 5081281..fc936a2 100644 --- a/thrimbletrimmer/scripts/edit.js +++ b/thrimbletrimmer/scripts/edit.js @@ -282,7 +282,6 @@ window.addEventListener("DOMContentLoaded", async (event) => { addError("Couldn't preview thumbnail; couldn't parse thumbnail frame timestamp"); return; } - const imageTemplate = document.getElementById("video-info-thumbnail-template").value; const videoFrameQuery = new URLSearchParams({ timestamp: imageTime, }); @@ -293,7 +292,16 @@ window.addEventListener("DOMContentLoaded", async (event) => { "video-info-thumbnail-template-overlay-image", ); - templateImageElement.src = `/thrimshim/template/${imageTemplate}.png`; + const thumbnailMode = document.getElementById("video-info-thumbnail-mode").value; + if (thumbnailMode === "TEMPLATE") { + const imageTemplate = document.getElementById("video-info-thumbnail-template").value; + templateImageElement.src = `/thrimshim/template/${imageTemplate}.png`; + } else if (thumbnailMode === "ONEOFF") { + const templateData = await uploadedImageToBase64(); + templateImageElement.src = `data:image/png;base64,${templateData}`; + } else { + console.log(`WARNING: Source images updated but thumbnailMode = ${thumbnailMode}`); + } templateImageElement.classList.remove("hidden"); const aspectRatioControls = document.getElementById(