From c466e0c279552995b0f0847038badf9d50be01c6 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Tue, 27 Feb 2024 18:01:47 +0800 Subject: [PATCH] Broken image fallbacks --- src/pages/catchup.jsx | 108 +++++++++++++++++++++++++----------------- 1 file changed, 65 insertions(+), 43 deletions(-) diff --git a/src/pages/catchup.jsx b/src/pages/catchup.jsx index d05e9f31..7aa86c87 100644 --- a/src/pages/catchup.jsx +++ b/src/pages/catchup.jsx @@ -1261,49 +1261,71 @@ function PostPeek({ post, filterInfo }) { )} {!!mediaAttachments?.length - ? mediaAttachments.map((m) => ( - - {{ - image: - (m.previewUrl || m.url) && showMedia ? ( - {m.description} - ) : ( - 🖼 - ), - gifv: - m.previewUrl && showMedia ? ( - {m.description} - ) : ( - 🎞️ - ), - video: - m.previewUrl && showMedia ? ( - {m.description} - ) : ( - 📹 - ), - audio: 🎵, - }[m.type] || null} - - )) + ? mediaAttachments.map((m) => { + const mediaURL = m.previewUrl || m.url; + const remoteMediaURL = m.previewRemoteUrl || m.remoteUrl; + return ( + + {{ + image: + (mediaURL || remoteMediaURL) && showMedia ? ( + {m.description} { + const { src } = e.target; + if (src === mediaURL) { + e.target.src = remoteMediaURL; + } + }} + /> + ) : ( + 🖼 + ), + gifv: + (mediaURL || remoteMediaURL) && showMedia ? ( + {m.description} { + const { src } = e.target; + if (src === mediaURL) { + e.target.src = remoteMediaURL; + } + }} + /> + ) : ( + 🎞️ + ), + video: + (mediaURL || remoteMediaURL) && showMedia ? ( + {m.description} { + const { src } = e.target; + if (src === mediaURL) { + e.target.src = remoteMediaURL; + } + }} + /> + ) : ( + 📹 + ), + audio: 🎵, + }[m.type] || null} + + ); + }) : !!card && card.image && showMedia && (