diff --git a/app.py b/app.py index 296e93f..7ee8fe1 100644 --- a/app.py +++ b/app.py @@ -1074,25 +1074,16 @@ def submission_detail(sub_id: int): _, ext = os.path.splitext(path) mime = mime_map.get(ext.lower(), "application/octet-stream") try: - with open(path, "rb") as f: - b64 = base64.b64encode(f.read()).decode() - src = f"data:{mime};base64,{b64}" + basename = os.path.basename(path) + src = f"/media/{basename}" media_html += f'
' # Media element if mime.startswith("image/"): - media_html += f'' + media_html += f'' elif mime.startswith("video/"): - # Generate thumbnail for poster thumb = generate_video_thumbnail(path) - poster_attr = "" - if thumb: - try: - with open(thumb, "rb") as tf: - thumb_b64 = base64.b64encode(tf.read()).decode() - poster_attr = f' poster="data:image/jpeg;base64,{thumb_b64}"' - except Exception: - pass - media_html += f'' + poster_attr = f' poster="/media/{os.path.basename(thumb)}"' if thumb else "" + media_html += f'' elif mime.startswith("audio/"): media_html += f'' else: @@ -1711,17 +1702,21 @@ def public_frontend(): continue if not os.path.exists(path): continue + basename = os.path.basename(path) _, ext = os.path.splitext(path) mime = mime_map.get(ext.lower(), "application/octet-stream") try: - with open(path, "rb") as f: - b64 = base64.b64encode(f.read()).decode() - src = "data:" + mime + ";base64," + b64 if mime.startswith("image/"): + # Use thumbnail for frontend cards + thumb = generate_image_thumbnail(path) + if thumb: + img_src = f"/media/{os.path.basename(thumb)}" + else: + img_src = f"/media/{basename}" img_tag = ( '' '
' - 'Beitragsbild' + 'Beitragsbild' '
' ) if i == 0 and not media_first: @@ -1730,16 +1725,11 @@ def public_frontend(): media_html += img_tag elif mime.startswith("video/"): thumb = generate_video_thumbnail(path) - if thumb: - with open(thumb, "rb") as f: - thumb_b64 = base64.b64encode(f.read()).decode() - thumb_src = "data:image/jpeg;base64," + thumb_b64 - else: - thumb_src = "" + thumb_src = f"/media/{os.path.basename(thumb)}" if thumb else "" vid_tag = ( '' '
' - + (f'Video-Vorschau' if thumb_src else '
🎬
') + + (f'Video-Vorschau' if thumb_src else '
🎬
') + '
' + '' + '
' @@ -2059,7 +2049,7 @@ def public_frontend():
Hey! 👋 Ich bin der BSN Community Assistant. Frag mich nach Spielen, Ständen oder was auf der SPIEL Essen los ist!
- +