Refac preemptive image fallback when url is undefined. Ticket: #911

This commit is contained in:
MerlinScheurer
2025-03-28 01:34:34 +01:00
parent 0aa5ef5b31
commit 2be190aa65
5 changed files with 35 additions and 5 deletions

View File

@@ -36,6 +36,12 @@ const VideoListItem = ({
return <p>No video found.</p>;
}
let videoThumbSrc = `${getApiUrl()}${video.vid_thumb_url}`;
if (video.vid_thumb_url === undefined) {
videoThumbSrc = defaultVideoThumb;
}
return (
<div className={`video-item ${viewLayout}`}>
<a
@@ -46,7 +52,7 @@ const VideoListItem = ({
<div className={`video-thumb-wrap ${viewLayout}`}>
<div className="video-thumb">
<img
src={`${getApiUrl()}${video.vid_thumb_url}`}
src={videoThumbSrc}
alt="video-thumb"
onError={({ currentTarget }) => {
currentTarget.onerror = null; // prevents looping