diff options
author | fuzzytent <fuzzy.tent6960@fastmail.com> | 2022-09-07 19:58:11 +0000 |
---|---|---|
committer | fuzzytent <fuzzy.tent6960@fastmail.com> | 2022-09-07 19:58:11 +0000 |
commit | 4d5a366f00de906b8ff5b124f7f7b6e771fee155 (patch) | |
tree | e9656009c43c9f6c3ebbb3e8491901dc1b3b76ec /script.js | |
parent | 296d012423f8d1862a63680443bb88b7d904ba4e (diff) | |
download | stable-diffusion-webui-gfx803-4d5a366f00de906b8ff5b124f7f7b6e771fee155.tar.gz stable-diffusion-webui-gfx803-4d5a366f00de906b8ff5b124f7f7b6e771fee155.tar.bz2 stable-diffusion-webui-gfx803-4d5a366f00de906b8ff5b124f7f7b6e771fee155.zip |
Allow copy-pasting images into file inputs
Diffstat (limited to 'script.js')
-rw-r--r-- | script.js | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -172,3 +172,19 @@ function submit(){ } return res } + +window.addEventListener('paste', e => { + const files = e.clipboardData.files; + if (!files || files.length !== 1) { + return; + } + if (!['image/png', 'image/gif', 'image/jpeg'].includes(files[0].type)) { + return; + } + [...gradioApp().querySelectorAll('input[type=file][accept="image/x-png,image/gif,image/jpeg"]')] + .filter(input => !input.matches('.\\!hidden input[type=file]')) + .forEach(input => { + input.files = files; + input.dispatchEvent(new Event('change')) + }); +}); |