mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-08 23:49:34 +00:00
Refac preemptive image fallback when url is undefined. Ticket: #911
This commit is contained in:
@@ -7,9 +7,15 @@ type ChannelIconProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const ChannelBanner = ({ channelId, channelBannerUrl }: ChannelIconProps) => {
|
const ChannelBanner = ({ channelId, channelBannerUrl }: ChannelIconProps) => {
|
||||||
|
let src = `${getApiUrl()}${channelBannerUrl}`;
|
||||||
|
|
||||||
|
if (channelBannerUrl === undefined) {
|
||||||
|
src = defaultChannelImage;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<img
|
<img
|
||||||
src={`${getApiUrl()}${channelBannerUrl}`}
|
src={src}
|
||||||
alt={`${channelId}-banner`}
|
alt={`${channelId}-banner`}
|
||||||
onError={({ currentTarget }) => {
|
onError={({ currentTarget }) => {
|
||||||
currentTarget.onerror = null; // prevents looping
|
currentTarget.onerror = null; // prevents looping
|
||||||
|
|||||||
@@ -7,9 +7,15 @@ type ChannelIconProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const ChannelIcon = ({ channelId, channelThumbUrl }: ChannelIconProps) => {
|
const ChannelIcon = ({ channelId, channelThumbUrl }: ChannelIconProps) => {
|
||||||
|
let src = `${getApiUrl()}${channelThumbUrl}`;
|
||||||
|
|
||||||
|
if (channelThumbUrl === undefined) {
|
||||||
|
src = defaultChannelIcon;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<img
|
<img
|
||||||
src={`${getApiUrl()}${channelThumbUrl}`}
|
src={src}
|
||||||
alt={`${channelId}-thumb`}
|
alt={`${channelId}-thumb`}
|
||||||
onError={({ currentTarget }) => {
|
onError={({ currentTarget }) => {
|
||||||
currentTarget.onerror = null; // prevents looping
|
currentTarget.onerror = null; // prevents looping
|
||||||
|
|||||||
@@ -22,12 +22,18 @@ const DownloadListItem = ({ download, setRefresh }: DownloadListItemProps) => {
|
|||||||
|
|
||||||
const [hideDownload, setHideDownload] = useState(false);
|
const [hideDownload, setHideDownload] = useState(false);
|
||||||
|
|
||||||
|
let src = `${getApiUrl()}${download.vid_thumb_url}`;
|
||||||
|
|
||||||
|
if (download.vid_thumb_url === undefined) {
|
||||||
|
src = defaultVideoThumb;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`video-item ${view}`} id={`dl-${download.youtube_id}`}>
|
<div className={`video-item ${view}`} id={`dl-${download.youtube_id}`}>
|
||||||
<div className={`video-thumb-wrap ${view}`}>
|
<div className={`video-thumb-wrap ${view}`}>
|
||||||
<div className="video-thumb">
|
<div className="video-thumb">
|
||||||
<img
|
<img
|
||||||
src={`${getApiUrl()}${download.vid_thumb_url}`}
|
src={src}
|
||||||
alt="video_thumb"
|
alt="video_thumb"
|
||||||
onError={({ currentTarget }) => {
|
onError={({ currentTarget }) => {
|
||||||
currentTarget.onerror = null; // prevents looping
|
currentTarget.onerror = null; // prevents looping
|
||||||
|
|||||||
@@ -7,9 +7,15 @@ type PlaylistThumbnailProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const PlaylistThumbnail = ({ playlistId, playlistThumbnail }: PlaylistThumbnailProps) => {
|
const PlaylistThumbnail = ({ playlistId, playlistThumbnail }: PlaylistThumbnailProps) => {
|
||||||
|
let src = `${getApiUrl()}${playlistThumbnail}`;
|
||||||
|
|
||||||
|
if (playlistThumbnail === undefined) {
|
||||||
|
src = defaultPlaylistThumbnail;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<img
|
<img
|
||||||
src={`${getApiUrl()}${playlistThumbnail}`}
|
src={src}
|
||||||
alt={`${playlistId}-thumbnail`}
|
alt={`${playlistId}-thumbnail`}
|
||||||
onError={({ currentTarget }) => {
|
onError={({ currentTarget }) => {
|
||||||
currentTarget.onerror = null; // prevents looping
|
currentTarget.onerror = null; // prevents looping
|
||||||
|
|||||||
@@ -36,6 +36,12 @@ const VideoListItem = ({
|
|||||||
return <p>No video found.</p>;
|
return <p>No video found.</p>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let videoThumbSrc = `${getApiUrl()}${video.vid_thumb_url}`;
|
||||||
|
|
||||||
|
if (video.vid_thumb_url === undefined) {
|
||||||
|
videoThumbSrc = defaultVideoThumb;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`video-item ${viewLayout}`}>
|
<div className={`video-item ${viewLayout}`}>
|
||||||
<a
|
<a
|
||||||
@@ -46,7 +52,7 @@ const VideoListItem = ({
|
|||||||
<div className={`video-thumb-wrap ${viewLayout}`}>
|
<div className={`video-thumb-wrap ${viewLayout}`}>
|
||||||
<div className="video-thumb">
|
<div className="video-thumb">
|
||||||
<img
|
<img
|
||||||
src={`${getApiUrl()}${video.vid_thumb_url}`}
|
src={videoThumbSrc}
|
||||||
alt="video-thumb"
|
alt="video-thumb"
|
||||||
onError={({ currentTarget }) => {
|
onError={({ currentTarget }) => {
|
||||||
currentTarget.onerror = null; // prevents looping
|
currentTarget.onerror = null; // prevents looping
|
||||||
|
|||||||
Reference in New Issue
Block a user