feat(import): enhance image URL extraction and logging during recipe import
This commit is contained in:
@@ -320,7 +320,9 @@ export class QuickImportService {
|
||||
let imageUrl: string | undefined;
|
||||
let imageWarning: string | undefined;
|
||||
if (recipe.imageUrl) {
|
||||
this.logger.log(`Bildkandidat från parser: ${recipe.imageUrl}`);
|
||||
const normalizedImageUrl = this.normalizeImageUrl(recipe.imageUrl, url);
|
||||
this.logger.log(`Normaliserad bild-URL: ${normalizedImageUrl ?? 'null'}`);
|
||||
if (!normalizedImageUrl) {
|
||||
imageWarning = 'Receptbild kunde inte tolkas till en giltig URL.';
|
||||
this.logger.warn(
|
||||
@@ -331,7 +333,9 @@ export class QuickImportService {
|
||||
imageUrl = await downloadAndOptimizeImage(normalizedImageUrl, IMAGE_DEST_DIR);
|
||||
this.logger.log(`Bild optimerad och sparad: ${imageUrl}`);
|
||||
} catch (imgErr) {
|
||||
imageWarning = 'Receptbild kunde inte laddas ner.';
|
||||
// Fallback: behåll extern URL så klienten ändå kan visa bild.
|
||||
imageUrl = normalizedImageUrl;
|
||||
imageWarning = 'Receptbild kunde inte laddas ner lokalt; extern URL används.';
|
||||
this.logger.warn(
|
||||
`Kunde inte ladda ner bild: ${imgErr} (källa: ${normalizedImageUrl})`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user