diff --git a/.env.defaults b/.env.defaults index 1c519e9bb..ad0c8fc59 100644 --- a/.env.defaults +++ b/.env.defaults @@ -50,6 +50,7 @@ YRBL_SAD_IMG_URL=https://cdn.lbryplayer.xyz/api/v3/streams/free/yrbl-sad/c2d9649 #LOGO_TEXT_LIGHT=https://cdn.lbryplayer.xyz/api/v3/streams/free/yrbl-sad/c2d9649633d974e5ffb503925e1f17d951f1bd0f/f262dd #LOGO_TEXT_DARK=https://cdn.lbryplayer.xyz/api/v3/streams/free/yrbl-sad/c2d9649633d974e5ffb503925e1f17d951f1bd0f/f262dd #AVATAR_DEFAULT= +#MISSING_THUMB_DEFAULT= #FAVICON= # LOCALE diff --git a/config.js b/config.js index a6c6b2a5c..009aedea6 100644 --- a/config.js +++ b/config.js @@ -34,6 +34,7 @@ const config = { LOGO_TEXT_LIGHT: process.env.LOGO_TEXT_LIGHT, LOGO_TEXT_DARK: process.env.LOGO_TEXT_DARK, AVATAR_DEFAULT: process.env.AVATAR_DEFAULT, + MISSING_THUMB_DEFAULT: process.env.MISSING_THUMB_DEFAULT, // OG OG_TITLE_SUFFIX: process.env.OG_TITLE_SUFFIX, OG_HOMEPAGE_TITLE: process.env.OG_HOMEPAGE_TITLE, diff --git a/ui/component/fileThumbnail/thumb.jsx b/ui/component/fileThumbnail/thumb.jsx index 64f11c138..6f9e823a9 100644 --- a/ui/component/fileThumbnail/thumb.jsx +++ b/ui/component/fileThumbnail/thumb.jsx @@ -6,17 +6,23 @@ import useLazyLoading from 'effects/use-lazy-loading'; type Props = { thumb: string, + fallback: ?string, children?: Node, className?: string, }; const Thumb = (props: Props) => { - const { thumb, children, className } = props; + const { thumb, fallback, children, className } = props; const thumbnailRef = React.useRef(null); useLazyLoading(thumbnailRef); return ( -
+
{children}
); diff --git a/ui/component/fileThumbnail/view.jsx b/ui/component/fileThumbnail/view.jsx index 6da4e513c..a5ef83ab6 100644 --- a/ui/component/fileThumbnail/view.jsx +++ b/ui/component/fileThumbnail/view.jsx @@ -4,6 +4,7 @@ import { getThumbnailCdnUrl } from 'util/thumbnail'; import React from 'react'; import FreezeframeWrapper from './FreezeframeWrapper'; import Placeholder from './placeholder.png'; +import { MISSING_THUMB_DEFAULT } from 'config'; import classnames from 'classnames'; import Thumb from './thumb'; @@ -42,6 +43,8 @@ function FileThumbnail(props: Props) { ); } + const fallback = MISSING_THUMB_DEFAULT ? getThumbnailCdnUrl({ thumbnail: MISSING_THUMB_DEFAULT }) : undefined; + let url = thumbnail || (hasResolvedClaim ? Placeholder : ''); // @if TARGET='web' // Pass image urls through a compression proxy @@ -54,7 +57,7 @@ function FileThumbnail(props: Props) { if (hasResolvedClaim || thumbnailUrl) { return ( - + {children} ); diff --git a/ui/effects/use-lazy-loading.js b/ui/effects/use-lazy-loading.js index 8e9ed8555..439d43d4d 100644 --- a/ui/effects/use-lazy-loading.js +++ b/ui/effects/use-lazy-loading.js @@ -47,7 +47,11 @@ export default function useLazyLoading( // useful for lazy loading background images on divs if (target.dataset.backgroundImage) { - target.style.backgroundImage = `url(${target.dataset.backgroundImage})`; + if (target.dataset.backgroundImageFallback) { + target.style.backgroundImage = `url(${target.dataset.backgroundImage}), url(${target.dataset.backgroundImageFallback})`; + } else { + target.style.backgroundImage = `url(${target.dataset.backgroundImage})`; + } } } });