From 3a29812319081efeea982a5ce31ead5612f522ad Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 21 Jan 2026 21:07:26 +0000 Subject: [PATCH] Fix gallery to use image_urls only, not media_urls media_urls is for video files, image_urls is for images. Updated PostDetailModal.jsx and markerManager.js to exclude media_urls from gallery image collection. Co-Authored-By: Claude Opus 4.5 --- src/components/Map/markerManager.js | 7 ++----- src/components/Posts/PostDetailModal.jsx | 6 +++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/components/Map/markerManager.js b/src/components/Map/markerManager.js index 3f25375..e96e61d 100644 --- a/src/components/Map/markerManager.js +++ b/src/components/Map/markerManager.js @@ -805,15 +805,12 @@ function collectGalleryImages(post) { seenBase.add(base); result.push(normalized); }; - // Check both media_urls (frontend) and image_urls (backend API) - these are actual galleries - if (Array.isArray(post?.media_urls)) { - post.media_urls.forEach(add); - } + // Only use image_urls for galleries (media_urls is for videos) if (Array.isArray(post?.image_urls)) { post.image_urls.forEach(add); } // Single images - prefer large > medium > small (dedupe by base name) - ["image_large", "image_medium", "image_small", "image", "media_url"].forEach((key) => { + ["image_large", "image_medium", "image_small", "image"].forEach((key) => { add(post?.[key]); }); return result; diff --git a/src/components/Posts/PostDetailModal.jsx b/src/components/Posts/PostDetailModal.jsx index 52205ea..079463c 100644 --- a/src/components/Posts/PostDetailModal.jsx +++ b/src/components/Posts/PostDetailModal.jsx @@ -586,6 +586,7 @@ export default function PostDetailModal({ post, onClose, onPostUpdated, onPostDe const author = post?.author || post?.username || post?.source_name || t("common.anon"); // Media gallery - dedupe by base filename (ignore size variants like _large, _medium, _small, _l, _m, _s) + // Note: media_urls is for videos only, image_urls is for images const gallery = useMemo(() => { const seen = new Set(); const seenBase = new Set(); @@ -606,11 +607,10 @@ export default function PostDetailModal({ post, onClose, onPostUpdated, onPostDe seenBase.add(base); images.push(n); }; - // Add from arrays first (user-uploaded galleries) - [post?.media_urls, post?.image_urls].forEach(arr => arr?.forEach(add)); + // Add from image_urls array first (user-uploaded galleries) - NOT media_urls (that's for videos) + post?.image_urls?.forEach(add); // Then single images (prefer large > medium > small) [post?.image_large, post?.image_medium, post?.image_small, post?.image_url, post?.image].forEach(add); - post?.media?.forEach(m => add(m?.url || m?.thumbnail_url)); return images; }, [post]);