From 0b6ba21f52e176a0a579eda7dbfe9d628ae0f062 Mon Sep 17 00:00:00 2001 From: pythongosssss <125205205+pythongosssss@users.noreply.github.com> Date: Tue, 21 Mar 2023 08:00:13 +0000 Subject: [PATCH] Added save image menu item --- web/scripts/app.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/web/scripts/app.js b/web/scripts/app.js index 3f06629e..dc61c5a6 100644 --- a/web/scripts/app.js +++ b/web/scripts/app.js @@ -80,10 +80,23 @@ class ComfyApp { img = this.imgs[this.overIndex]; } if (img) { - options.unshift({ - content: "Open Image", - callback: () => window.open(img.src, "_blank"), - }); + options.unshift( + { + content: "Open Image", + callback: () => window.open(img.src, "_blank"), + }, + { + content: "Save Image", + callback: () => { + const a = document.createElement("a"); + a.href = img.src; + a.setAttribute("download", new URLSearchParams(new URL(img.src).search).get("filename")); + document.body.append(a); + a.click(); + requestAnimationFrame(() => a.remove()); + }, + } + ); } } };