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 <noreply@anthropic.com>
This commit is contained in:
parent
081fba7244
commit
3a29812319
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue