mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-23 17:16:26 +01:00
Broken image fallbacks
This commit is contained in:
parent
b913c8817d
commit
c466e0c279
1 changed files with 65 additions and 43 deletions
|
@ -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 && (
|
||||||
|
|
Loading…
Reference in a new issue