diff --git a/javascript/image_browser.js b/javascript/image_browser.js index c47069c..dbcb930 100644 --- a/javascript/image_browser.js +++ b/javascript/image_browser.js @@ -430,6 +430,10 @@ function image_browser_init() { btn.removeEventListener('click', () => btnClickHandler(tab_base_tag, btn)) btn.addEventListener('click', () => btnClickHandler(tab_base_tag, btn)) }) + //preload + if (gradioApp().getElementById("image_browser_preload").querySelector("input").checked) { + setTimeout(function(){tab_btns[0].click()}, 100) + } } image_browser_keydown() diff --git a/scripts/image_browser.py b/scripts/image_browser.py index c3934c2..83fddd3 100644 --- a/scripts/image_browser.py +++ b/scripts/image_browser.py @@ -1631,6 +1631,7 @@ def on_ui_tabs(): with gr.Tab(tab.name, elem_id=f"{tab.base_tag}_image_browser_container") as current_gr_tab: with gr.Blocks(analytics_enabled=False): create_tab(tab, current_gr_tab) + gr.Checkbox(value=opts.image_browser_preload, elem_id="image_browser_preload", visible=False) gr.Textbox(",".join( [tab.base_tag for tab in tabs_list] ), elem_id="image_browser_tab_base_tags_list", visible=False) gr.Checkbox(value=opts.image_browser_swipe, elem_id=f"image_browser_swipe") @@ -1675,6 +1676,7 @@ def on_ui_settings(): ("image_browser_active_tabs", None, ", ".join(default_tab_options), active_tabs_description), ("image_browser_hidden_components", None, [], "Select components to hide", DropdownMulti, lambda: {"choices": components_list}), ("image_browser_with_subdirs", "images_history_with_subdirs", True, "Include images in sub directories"), + ("image_browser_preload", "images_history_preload", False, "Preload images at startup for first tab"), ("image_browser_copy_image", "images_copy_image", False, "Move buttons copy instead of move"), ("image_browser_delete_message", "images_delete_message", True, "Print image deletion messages to the console"), ("image_browser_txt_files", "images_txt_files", True, "Move/Copy/Delete matching .txt files"),