make existing image browser extension not break

This commit is contained in:
AUTOMATIC 2022-10-29 09:01:04 +03:00
parent af547f63c3
commit 2922d8144f

View File

@ -53,6 +53,13 @@ def image_from_url_text(filedata):
def add_paste_fields(tabname, init_img, fields):
paste_fields[tabname] = {"init_img": init_img, "fields": fields}
# backwards compatibility for existing extensions
import modules.ui
if tabname == 'txt2img':
modules.ui.txt2img_paste_fields = fields
elif tabname == 'img2img':
modules.ui.img2img_paste_fields = fields
def create_buttons(tabs_list):
buttons = {}
@ -154,7 +161,8 @@ Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 965400086, Size: 512x512, Model
return res
def connect_paste(button, paste_fields, input_comp):
def connect_paste(button, paste_fields, input_comp, jsfunc=None):
def paste_func(prompt):
if not prompt and not shared.cmd_opts.hide_ui_dir_config:
filename = os.path.join(script_path, "params.txt")
@ -192,6 +200,7 @@ def connect_paste(button, paste_fields, input_comp):
button.click(
fn=paste_func,
_js=jsfunc,
inputs=[input_comp],
outputs=[x[0] for x in paste_fields],
)