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