File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -264,13 +264,18 @@ def main():
264264 # print(f" Image for '{recipe_name_fr}' is a URL: {image_filename_val}")
265265 pass # Keep the URL as is
266266
267- output_html_filename_str = generate_safe_filename (
268- recipe_name_fr , extension = "html"
269- )
270- output_pdf_filename_str = generate_safe_filename (
271- recipe_name_fr , extension = "pdf"
272- )
273- # Chemin relatif depuis la page HTML (dans OUTPUT_DIR) vers le PDF (dans OUTPUT_PDF_DIR)
267+ # Détermination du chemin de l'image pour le template (URL ou chemin local)
268+ image_path = None
269+ if image_filename_val :
270+ if image_filename_val .startswith (("http://" , "https://" )):
271+ image_path = image_filename_val
272+ else :
273+ image_path = f"{ OUTPUT_RECIPE_IMAGES_DIR .name } /{ image_filename_val } "
274+ recipe_data ["image_path" ] = image_path
275+
276+ # Génération des noms de fichiers de sortie HTML et PDF (corrige le NameError)
277+ output_html_filename_str = generate_safe_filename (recipe_name_fr , extension = "html" )
278+ output_pdf_filename_str = generate_safe_filename (recipe_name_fr , extension = "pdf" )
274279 recipe_data ["pdf_path" ] = f"{ OUTPUT_PDF_DIR .name } /{ output_pdf_filename_str } "
275280
276281 # Context for rendering the individual recipe page
Original file line number Diff line number Diff line change @@ -128,8 +128,8 @@ <h2>Instructions</h2>
128128 <!-- <span class="separation-line"></span> --> {# Ligne de séparation si besoin avant le footer #}
129129 {% endif %}
130130
131- {% if recipe.image_filename %}
132- < img src ="recipe_images/ {{ recipe.image_filename }} " alt ="Illustration de {{ recipe.name }} "/>
131+ {% if recipe.image_path %}
132+ < img src ="{{ recipe.image_path }} " alt ="Illustration de {{ recipe.name }} "/>
133133 {% else %}
134134 <!-- Optionnel: une image placeholder si aucune image n'est fournie -->
135135 <!-- <img src="placeholder.jpg" alt="Pas d'image disponible" /> -->
@@ -143,4 +143,4 @@ <h2>Instructions</h2>
143143 Recette générée avec ❤️
144144</ footer >
145145</ body >
146- </ html >
146+ </ html >
Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ <h2>Instructions</h2>
154154
155155
156156
157- < img src ="recipe_images/ https://img.cuisineaz.com/660x495/2015/01/29/i113699-photo-de-crepe-facile.webp " alt ="Illustration de Crêpes "/>
157+ < img src ="https://img.cuisineaz.com/660x495/2015/01/29/i113699-photo-de-crepe-facile.webp " alt ="Illustration de Crêpes "/>
158158
159159 </ div >
160160 </ section >
Original file line number Diff line number Diff line change @@ -136,7 +136,7 @@ <h2>Instructions</h2>
136136
137137
138138
139- < img src ="recipe_images/ https://example.com/path/to/image.jpg " alt ="Illustration de Nom de la recette "/>
139+ < img src ="https://example.com/path/to/image.jpg " alt ="Illustration de Nom de la recette "/>
140140
141141 </ div >
142142 </ section >
You can’t perform that action at this time.
0 commit comments