mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 15:15:44 -03:00
fix(recipes): use preview endpoint for recipe images
This commit is contained in:
@@ -206,18 +206,16 @@ class RecipeListingHandler:
|
|||||||
|
|
||||||
def format_recipe_file_url(self, file_path: str) -> str:
|
def format_recipe_file_url(self, file_path: str) -> str:
|
||||||
try:
|
try:
|
||||||
recipes_dir = os.path.join(config.loras_roots[0], "recipes").replace(os.sep, "/")
|
normalized_path = os.path.normpath(file_path)
|
||||||
normalized_path = file_path.replace(os.sep, "/")
|
static_url = config.get_preview_static_url(normalized_path)
|
||||||
if normalized_path.startswith(recipes_dir):
|
if static_url:
|
||||||
relative_path = os.path.relpath(file_path, config.loras_roots[0]).replace(os.sep, "/")
|
return static_url
|
||||||
return f"/loras_static/root1/preview/{relative_path}"
|
|
||||||
|
|
||||||
file_name = os.path.basename(file_path)
|
|
||||||
return f"/loras_static/root1/preview/recipes/{file_name}"
|
|
||||||
except Exception as exc: # pragma: no cover - logging path
|
except Exception as exc: # pragma: no cover - logging path
|
||||||
self._logger.error("Error formatting recipe file URL: %s", exc, exc_info=True)
|
self._logger.error("Error formatting recipe file URL: %s", exc, exc_info=True)
|
||||||
return "/loras_static/images/no-preview.png"
|
return "/loras_static/images/no-preview.png"
|
||||||
|
|
||||||
|
return "/loras_static/images/no-preview.png"
|
||||||
|
|
||||||
|
|
||||||
class RecipeQueryHandler:
|
class RecipeQueryHandler:
|
||||||
"""Provide read-only insights on recipe data."""
|
"""Provide read-only insights on recipe data."""
|
||||||
|
|||||||
@@ -744,19 +744,16 @@ class RecipeScanner:
|
|||||||
return '/loras_static/images/no-preview.png'
|
return '/loras_static/images/no-preview.png'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Format file path as a URL that will work with static file serving
|
normalized_path = os.path.normpath(file_path)
|
||||||
recipes_dir = os.path.join(config.loras_roots[0], "recipes").replace(os.sep, '/')
|
static_url = config.get_preview_static_url(normalized_path)
|
||||||
if file_path.replace(os.sep, '/').startswith(recipes_dir):
|
if static_url:
|
||||||
relative_path = os.path.relpath(file_path, config.loras_roots[0]).replace(os.sep, '/')
|
return static_url
|
||||||
return f"/loras_static/root1/preview/{relative_path}"
|
|
||||||
|
|
||||||
# If not in recipes dir, try to create a valid URL from the file name
|
|
||||||
file_name = os.path.basename(file_path)
|
|
||||||
return f"/loras_static/root1/preview/recipes/{file_name}"
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error formatting file URL: {e}")
|
logger.error(f"Error formatting file URL: {e}")
|
||||||
return '/loras_static/images/no-preview.png'
|
return '/loras_static/images/no-preview.png'
|
||||||
|
|
||||||
|
return '/loras_static/images/no-preview.png'
|
||||||
|
|
||||||
def _format_timestamp(self, timestamp: float) -> str:
|
def _format_timestamp(self, timestamp: float) -> str:
|
||||||
"""Format timestamp for display"""
|
"""Format timestamp for display"""
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|||||||
Reference in New Issue
Block a user