diff --git a/modules/shared_options.py b/modules/shared_options.py index 179c49af..17ba5470 100644 --- a/modules/shared_options.py +++ b/modules/shared_options.py @@ -384,6 +384,7 @@ options_templates.update( "sd_webui_modal_lightbox_toolbar_opacity": OptionInfo(0.9, "[Lightbox]: tool bar opacity", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.05}, onchange=shared.reload_gradio_theme).info("for mouse only").needs_reload_ui(), "open_dir_button_choice": OptionInfo("Subdirectory", "What directory the [📂] button opens", gr.Radio, {"choices": ("Output Root", "Subdirectory", "Subdirectory (even temp dir)")}), "hires_button_gallery_insert": OptionInfo(False, "When using the [✨] button, insert the upscaled image to the gallery").info("otherwise replace the selected image in the gallery"), + "hires_insert_index": OptionInfo(True, "When the above option is enabled, automatically select the upscaled image").info("otherwise select the original image"), }, ) ) diff --git a/modules/txt2img.py b/modules/txt2img.py index 85ac9a2f..dbd4696a 100644 --- a/modules/txt2img.py +++ b/modules/txt2img.py @@ -111,14 +111,15 @@ def txt2img_upscale_function(id_task: str, request: gr.Request, gallery, gallery if i == gallery_index: new_gallery.extend(processed.images) - new_index = gallery_index if insert: - new_index += 1 + new_index = gallery_index + 1 geninfo["infotexts"].insert(new_index, processed.info) + if not getattr(shared.opts, "hires_insert_index", True): + gallery_index -= 1 else: geninfo["infotexts"][gallery_index] = processed.info - return new_gallery, json.dumps(geninfo), plaintext_to_html(processed.info), plaintext_to_html(processed.comments, classname="comments") + return gr.update(value=new_gallery, selected_index=gallery_index), json.dumps(geninfo), plaintext_to_html(processed.info), plaintext_to_html(processed.comments, classname="comments") def txt2img_function(id_task: str, request: gr.Request, *args):