Broken image fallbacks

This commit is contained in:
Lim Chee Aun 2024-02-27 18:01:47 +08:00
parent b913c8817d
commit c466e0c279

View file

@ -1261,49 +1261,71 @@ function PostPeek({ post, filterInfo }) {
</span> </span>
)} )}
{!!mediaAttachments?.length {!!mediaAttachments?.length
? mediaAttachments.map((m) => ( ? mediaAttachments.map((m) => {
<span key={m.id} class="post-peek-media"> const mediaURL = m.previewUrl || m.url;
{{ const remoteMediaURL = m.previewRemoteUrl || m.remoteUrl;
image: return (
(m.previewUrl || m.url) && showMedia ? ( <span key={m.id} class="post-peek-media">
<img {{
src={m.previewUrl || m.url} image:
width={MEDIA_SIZE} (mediaURL || remoteMediaURL) && showMedia ? (
height={MEDIA_SIZE} <img
alt={m.description} src={mediaURL}
loading="lazy" width={MEDIA_SIZE}
/> height={MEDIA_SIZE}
) : ( alt={m.description}
<span class="post-peek-faux-media">🖼</span> loading="lazy"
), onError={(e) => {
gifv: const { src } = e.target;
m.previewUrl && showMedia ? ( if (src === mediaURL) {
<img e.target.src = remoteMediaURL;
src={m.previewUrl} }
width={MEDIA_SIZE} }}
height={MEDIA_SIZE} />
alt={m.description} ) : (
loading="lazy" <span class="post-peek-faux-media">🖼</span>
/> ),
) : ( gifv:
<span class="post-peek-faux-media">🎞</span> (mediaURL || remoteMediaURL) && showMedia ? (
), <img
video: src={mediaURL}
m.previewUrl && showMedia ? ( width={MEDIA_SIZE}
<img height={MEDIA_SIZE}
src={m.previewUrl} alt={m.description}
width={MEDIA_SIZE} loading="lazy"
height={MEDIA_SIZE} onError={(e) => {
alt={m.description} const { src } = e.target;
loading="lazy" if (src === mediaURL) {
/> e.target.src = remoteMediaURL;
) : ( }
<span class="post-peek-faux-media">📹</span> }}
), />
audio: <span class="post-peek-faux-media">🎵</span>, ) : (
}[m.type] || null} <span class="post-peek-faux-media">🎞</span>
</span> ),
)) video:
(mediaURL || remoteMediaURL) && showMedia ? (
<img
src={mediaURL}
width={MEDIA_SIZE}
height={MEDIA_SIZE}
alt={m.description}
loading="lazy"
onError={(e) => {
const { src } = e.target;
if (src === mediaURL) {
e.target.src = remoteMediaURL;
}
}}
/>
) : (
<span class="post-peek-faux-media">📹</span>
),
audio: <span class="post-peek-faux-media">🎵</span>,
}[m.type] || null}
</span>
);
})
: !!card && : !!card &&
card.image && card.image &&
showMedia && ( showMedia && (