Skip to content

Commit

Permalink
Add a 'Remove Image' button to clear the file upload field (#382)
Browse files Browse the repository at this point in the history
* added "remove image" button

* styled a new "remove image" button

* Update index.js
  • Loading branch information
arice authored Sep 5, 2022
1 parent 95c088b commit caf4ea3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion static/dream_web/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ div {
padding: 5px 10px 5px 10px;
border: 1px solid black;
}
#reset-all {
#reset-all, #remove-image {
background-color: pink;
}
#results {
Expand Down
1 change: 1 addition & 0 deletions static/dream_web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ <h2 id="header">Stable Diffusion Dream Server</h2>
<div id="img2img">
<label title="Upload an image to use img2img" for="initimg">Initial image:</label>
<input type="file" id="initimg" name="initimg" accept=".jpg, .jpeg, .png">
<button type="button" id="remove-image">Remove Image</button>
<br>
<label for="strength">Img2Img Strength:</label>
<input value="0.75" type="number" id="strength" name="strength" step="0.01" min="0" max="1">
Expand Down
3 changes: 3 additions & 0 deletions static/dream_web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ window.onload = () => {
document.querySelector("#reset-all").addEventListener('click', (e) => {
clearFields(e.target.form);
});
document.querySelector("#remove-image").addEventListener('click', (e) => {
initimg.value=null;
});
loadFields(document.querySelector("#generate-form"));

document.querySelector('#cancel-button').addEventListener('click', () => {
Expand Down

0 comments on commit caf4ea3

Please sign in to comment.