Skip to content

Commit

Permalink
Merge pull request #13459 from wkpark/preview-fix
Browse files Browse the repository at this point in the history
show the preview image in the modalview if available
  • Loading branch information
AUTOMATIC1111 committed Oct 14, 2023
2 parents 0619df9 + dbb10fb commit 771dac9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions javascript/imageviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ function updateOnBackgroundChange() {
const modalImage = gradioApp().getElementById("modalImage");
if (modalImage && modalImage.offsetParent) {
let currentButton = selected_gallery_button();

if (currentButton?.children?.length > 0 && modalImage.src != currentButton.children[0].src) {
let preview = gradioApp().querySelectorAll('.livePreview > img');
if (preview.length > 0) {
// show preview image if available
modalImage.src = preview[preview.length - 1].src;
} else if (currentButton?.children?.length > 0 && modalImage.src != currentButton.children[0].src) {
modalImage.src = currentButton.children[0].src;
if (modalImage.style.display === 'none') {
const modal = gradioApp().getElementById("lightboxModal");
Expand Down

0 comments on commit 771dac9

Please sign in to comment.