Merge origin/main into feature/button
Resolve conflicts in py/api.py by keeping feature/button's thumbnail
path generation approach (using rel_path.with_suffix('') and string
formatting) which was tested and working correctly.
This commit is contained in:
@@ -1067,7 +1067,8 @@ class PromptManagerAPI:
|
||||
thumbnail_abs_path = output_path / thumbnail_rel_path
|
||||
|
||||
if thumbnail_abs_path.exists():
|
||||
thumbnail_url = f'/prompt_manager/images/serve/{Path(thumbnail_rel_path).as_posix()}'
|
||||
from urllib.parse import quote
|
||||
thumbnail_url = f'/prompt_manager/images/serve/{quote(thumbnail_rel_path.as_posix(), safe="/")}'
|
||||
|
||||
image_info = {
|
||||
'id': str(hash(str(media_path))),
|
||||
@@ -1950,6 +1951,7 @@ class PromptManagerAPI:
|
||||
thumbnail_url = None
|
||||
if thumbnails_dir.exists():
|
||||
# For videos, look for thumbnail with .jpg extension
|
||||
# Use full relative path to support subdirectories
|
||||
thumbnail_ext = '.jpg' if is_video else extension
|
||||
# Preserve subdirectory structure in thumbnail path
|
||||
rel_path_no_ext = rel_path.with_suffix('')
|
||||
@@ -1957,7 +1959,8 @@ class PromptManagerAPI:
|
||||
thumbnail_abs_path = output_path / thumbnail_rel_path
|
||||
|
||||
if thumbnail_abs_path.exists():
|
||||
thumbnail_url = f'/prompt_manager/images/serve/{Path(thumbnail_rel_path).as_posix()}'
|
||||
from urllib.parse import quote
|
||||
thumbnail_url = f'/prompt_manager/images/serve/{quote(thumbnail_rel_path.as_posix(), safe="/")}'
|
||||
|
||||
images.append({
|
||||
'id': str(hash(str(media_path))), # Simple hash for ID
|
||||
|
||||
+17
-3
@@ -4713,14 +4713,28 @@ Seed: ${this.currentMetadata.seed || 'Unknown'}`;
|
||||
// If thumbnail_url already exists, use it
|
||||
if (image.thumbnail_url) return image.thumbnail_url;
|
||||
|
||||
// Try to construct thumbnail URL from filename
|
||||
// Thumbnails are stored as: thumbnails/{stem}_thumb{ext}
|
||||
// Try to construct thumbnail URL from filename and relative_path
|
||||
// Thumbnails are stored as: thumbnails/{parent_dir}/{stem}_thumb{ext}
|
||||
// to avoid collisions with same-named files in different directories
|
||||
if (image.filename) {
|
||||
const lastDot = image.filename.lastIndexOf('.');
|
||||
if (lastDot > 0) {
|
||||
const stem = image.filename.substring(0, lastDot);
|
||||
const ext = image.filename.substring(lastDot);
|
||||
return `/prompt_manager/images/serve/thumbnails/${stem}_thumb${ext}`;
|
||||
|
||||
// Get parent directory from relative_path if available
|
||||
let parentDir = '';
|
||||
if (image.relative_path) {
|
||||
const relPath = image.relative_path.replace(/\\/g, '/');
|
||||
const lastSlash = relPath.lastIndexOf('/');
|
||||
if (lastSlash > 0) {
|
||||
parentDir = relPath.substring(0, lastSlash) + '/';
|
||||
}
|
||||
}
|
||||
|
||||
// URL encode the path components (but preserve slashes)
|
||||
const encodedParentDir = parentDir.split('/').map(p => encodeURIComponent(p)).join('/');
|
||||
return `/prompt_manager/images/serve/thumbnails/${encodedParentDir}${encodeURIComponent(stem)}_thumb${ext}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user