diff --git a/src/lib/components/RecipeView.svelte b/src/lib/components/RecipeView.svelte index 6b90c55..70de7fd 100644 --- a/src/lib/components/RecipeView.svelte +++ b/src/lib/components/RecipeView.svelte @@ -18,6 +18,16 @@ let tab = $state<'ing' | 'prep'>('ing'); + // In preview, image_path is still an external URL; after save, it's a local + // filename served under /images/. Detect absolute URLs and pass through. + const imageSrc = $derived( + recipe.image_path === null + ? null + : /^https?:\/\//i.test(recipe.image_path) + ? recipe.image_path + : `/images/${recipe.image_path}` + ); + function decr() { if (servings > 1) servingsOverride = servings - 1; } @@ -47,8 +57,8 @@
- {#if recipe.image_path} - + {#if imageSrc} + {/if}

{recipe.title}