From 9a212d13e7d3ca3aed405093b2520bbd9b3efabe Mon Sep 17 00:00:00 2001 From: Dijkstra Date: Thu, 31 Oct 2024 19:14:31 +0100 Subject: [PATCH] fix: sometimes the preview image extension is prefixed with '.preview' --- pyproject.toml | 2 +- utils.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f112aad..0e2fccc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-lora-auto-trigger-words" description = "The aim of these custom nodes is to get an easy access to the tags used to trigger a lora / lycoris. Extract the tags from civitai or from the safetensors metadatas when available." -version = "1.0.1" +version = "1.0.2" license = "MIT" [project.urls] diff --git a/utils.py b/utils.py index 92f0d35..bf16367 100644 --- a/utils.py +++ b/utils.py @@ -15,11 +15,14 @@ def get_preview_path(name, type): file_path_no_ext = os.path.splitext(file_path)[0] item_image=None - for ext in ["png", "jpg", "jpeg", "preview.png"]: - has_image = os.path.isfile(file_path_no_ext + "." + ext) - if has_image: - item_image = f"{file_name}.{ext}" + for ext in ["png", "jpg", "jpeg", "gif"]: + if item_image is not None: break + for ext2 in ["", ".preview"]: + has_image = os.path.isfile(file_path_no_ext + ext2 + "." + ext) + if has_image: + item_image = f"{file_name}{ext2}.{ext}" + break return has_image, item_image