diff --git a/static/css/components/recipe-modal.css b/static/css/components/recipe-modal.css index 0d5fa3b5..8f792cb5 100644 --- a/static/css/components/recipe-modal.css +++ b/static/css/components/recipe-modal.css @@ -129,7 +129,14 @@ justify-content: center; } -.recipe-preview-container img { +.recipe-preview-container img, +.recipe-preview-container video { + max-width: 100%; + max-height: 100%; + object-fit: contain; +} + +.recipe-preview-media { max-width: 100%; max-height: 100%; object-fit: contain; @@ -340,9 +347,19 @@ border-radius: var(--border-radius-xs); overflow: hidden; background: var(--bg-color); + display: flex; + align-items: center; + justify-content: center; } -.recipe-lora-thumbnail img { +.recipe-lora-thumbnail img, +.recipe-lora-thumbnail video { + width: 100%; + height: 100%; + object-fit: cover; +} + +.thumbnail-video { width: 100%; height: 100%; object-fit: cover; diff --git a/static/js/components/RecipeModal.js b/static/js/components/RecipeModal.js index 5f586827..e193af1b 100644 --- a/static/js/components/RecipeModal.js +++ b/static/js/components/RecipeModal.js @@ -107,8 +107,33 @@ class RecipeModal { const imageUrl = recipe.file_url || (recipe.file_path ? `/loras_static/root1/preview/${recipe.file_path.split('/').pop()}` : '/loras_static/images/no-preview.png'); - modalImage.src = imageUrl; - modalImage.alt = recipe.title || 'Recipe Preview'; + + // Check if the file is a video (mp4) + const isVideo = imageUrl.toLowerCase().endsWith('.mp4'); + + // Replace the image element with appropriate media element + const mediaContainer = modalImage.parentElement; + mediaContainer.innerHTML = ''; + + if (isVideo) { + const videoElement = document.createElement('video'); + videoElement.id = 'recipeModalVideo'; + videoElement.src = imageUrl; + videoElement.controls = true; + videoElement.autoplay = false; + videoElement.loop = true; + videoElement.muted = true; + videoElement.className = 'recipe-preview-media'; + videoElement.alt = recipe.title || 'Recipe Preview'; + mediaContainer.appendChild(videoElement); + } else { + const imgElement = document.createElement('img'); + imgElement.id = 'recipeModalImage'; + imgElement.src = imageUrl; + imgElement.className = 'recipe-preview-media'; + imgElement.alt = recipe.title || 'Recipe Preview'; + mediaContainer.appendChild(imgElement); + } } // Set generation parameters @@ -212,10 +237,18 @@ class RecipeModal { Not in Library `; + // Check if preview is a video + const isPreviewVideo = lora.preview_url && lora.preview_url.toLowerCase().endsWith('.mp4'); + const previewMedia = isPreviewVideo ? + `` : + `LoRA preview`; + return `
- LoRA preview + ${previewMedia}
diff --git a/templates/components/recipe_modal.html b/templates/components/recipe_modal.html index 1b791c5a..d760d78e 100644 --- a/templates/components/recipe_modal.html +++ b/templates/components/recipe_modal.html @@ -16,8 +16,8 @@