Skip to content

Commit

Permalink
fix: 🐛 image fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
heldrida committed Dec 13, 2021
1 parent 6278e27 commit aaa7e4d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/dashboard/src/components/ItemCell/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,17 @@ const IconDisplayer = ({
}: {
mediaUrl?: string,
}) => {
const isValidImgIcon = mediaUrl?.match(/.gif|.png|.jpg/);
let isValidImgIcon = !!mediaUrl?.match(/.gif|.png|.jpe?g/);
const isValidMediaIcon = mediaUrl?.match(/.mp4/);

if (!isValidImgIcon && !isValidMediaIcon && typeof mediaUrl !== 'undefined') {
// TODO: given that certain standards have URLs
// which do not have a png, jpg but valid
// maybe compute it here
// at time of writing it'll fallback to true
isValidImgIcon = true;
}

if (isValidMediaIcon) {
return (
<video data-icon-video controls width="35" loop autoPlay>
Expand Down Expand Up @@ -106,7 +114,7 @@ export default ({
)
: (
<IconDisplayer
mediaUrl={nftDetails?.url || metadata?.icon}
mediaUrl={nftDetails?.url || metadata?.icon}
/>
)
}
Expand Down

0 comments on commit aaa7e4d

Please sign in to comment.