Skip to content

Commit

Permalink
show the preview image in the modalview if available
Browse files Browse the repository at this point in the history
  • Loading branch information
wkpark committed Oct 1, 2023
1 parent e3c849d commit 57f0f6e
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 57f0f6e

Please sign in to comment.