diff --git a/.gitignore b/.gitignore index 1583181..72f001c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ scripts/__pycache__/ scripts/ch_lib/__pycache__/ setting.json +.idea \ No newline at end of file diff --git a/javascript/civitai_helper.js b/javascript/civitai_helper.js index 4454d0d..ee02245 100644 --- a/javascript/civitai_helper.js +++ b/javascript/civitai_helper.js @@ -430,7 +430,7 @@ onUiLoaded(() => { if (!extra_tabs) {console.log("can not find extra_tabs: " + tab_prefix+"_extra_tabs");} //get active extratab - const active_extra_tab = Array.from(get_uiCurrentTabContent().querySelectorAll('.extra-network-cards,.extra-network-thumbs')) + const active_extra_tab = Array.from(document.querySelectorAll('.extra-network-cards,.extra-network-thumbs')) .find(el => el.closest('.tabitem').style.display === 'block') ?.id.match(/^(txt2img|img2img)_(.+)_cards$/)[2] diff --git a/scripts/ch_lib/civitai.py b/scripts/ch_lib/civitai.py index 2a15ae7..affe4d7 100644 --- a/scripts/ch_lib/civitai.py +++ b/scripts/ch_lib/civitai.py @@ -319,16 +319,20 @@ def get_preview_image_by_model_path(model_path:str, max_size_preview, skip_nsfw_ return if not os.path.isfile(model_path): - util.printD("model_path is not a file: "+model_path) + util.printD("model_path is not a file: "+ model_path) return base, ext = os.path.splitext(model_path) + first_preview = base+".png" sec_preview = base+".preview.png" + + check_preview_files = [base + ext for ext in (".png", ".preview.png", ".jpg", ".preview.jpg", ".webp", ".preview.webp")] + info_file = base + suffix + model.info_ext # check preview image - if not os.path.isfile(sec_preview): + if not all(os.path.isfile(file) for file in check_preview_files): # need to download preview image util.printD("Checking preview image for model: " + model_path) # load model_info file