diff --git a/Web/app.py b/Web/app.py index 017e624..0d18962 100755 --- a/Web/app.py +++ b/Web/app.py @@ -3828,7 +3828,10 @@ def api_item_detail(item_id): """ client.close() - return detail_html, 200 + return jsonify({ + 'html': detail_html, + 'images': item.get('Images', item.get('Bilder', [])) + }), 200 except Exception as e: app.logger.error(f"Error fetching item detail: {e}") return jsonify({'error': 'An error occurred while fetching the item detail'}), 500 diff --git a/Web/templates/library_table.html b/Web/templates/library_table.html index 3e1f8b4..3cc28ee 100644 --- a/Web/templates/library_table.html +++ b/Web/templates/library_table.html @@ -1331,51 +1331,29 @@ detailContent.innerHTML = '

Lade Details...

'; detailModal.style.display = 'flex'; + // Sicherer Zugriff auf das Item mit Fallback const item = libraryItems.find(i => i._id === itemId); let mediaHtml = ''; - // Robuste Prüfung: Wir testen gängige Benennungen aus deinem Backend - const imageArray = item.Images || item.Bilder || item.images; + if (item) { + // Prüfe gängige Array-Namen aus dem Backend + const imageArray = item.Images || item.Bilder || item.images; - if (item && Array.isArray(imageArray) && imageArray.length > 0) { - const imagesHtml = imageArray.map((image, index) => { + if (Array.isArray(imageArray) && imageArray.length > 0) { + const imagesHtml = imageArray.map(image => { + // Direkter, robuster Pfad zur Upload-Route + const imageSrc = image.startsWith('/uploads/') || image.startsWith('http') + ? image + : `/uploads/${image}`; - // Dein neuer Code für die exakte Routen-Generierung - const imageSrc = image.startsWith('/uploads/') || image.startsWith('http') ? - image : - `{{ url_for('uploaded_file', filename='') }}${image}`; + return `${escapeHtml(item.Name || 'Medium')}`; + }).join(''); - const thumbnailInfo = item.ThumbnailInfo && item.ThumbnailInfo[index]; - const isVideo = isVideoFile(image); - - if (isVideo) { - const videoSrc = thumbnailInfo && thumbnailInfo.has_thumbnail - ? thumbnailInfo.thumbnail_url - : imageSrc; - - if (thumbnailInfo && thumbnailInfo.has_thumbnail) { - return ` -
- ${escapeHtml(item.Name || 'Medium')} -
- ▶ -
-
`; - } else { - return `
VIDEO
`; - } - } else { - const imageSrcFinal = thumbnailInfo && thumbnailInfo.has_thumbnail - ? thumbnailInfo.thumbnail_url - : imageSrc; - - return `${escapeHtml(item.Name || 'Medium')}`; - } - }).join(''); - - mediaHtml = ``; + mediaHtml = ``; + } } + // Zusätzliche Details vom Backend laden fetch(`/api/item_detail/${itemId}`) .then(response => { if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`); @@ -1390,7 +1368,7 @@ }); } - // Closes the modal via the 'x' button + // Schließt das Modal über den 'x'-Button function closeDetailModal() { document.getElementById('detailModal').style.display = 'none'; }