Skip to content

Commit

Permalink
Merge pull request #257 from reservoirprotocol/ted/fix-optimize-image…
Browse files Browse the repository at this point in the history
…-errors

Fix optimize image errors
  • Loading branch information
ted-palmer committed Jun 13, 2023
2 parents 753edb0 + 7e5f087 commit c493ff6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 18 deletions.
10 changes: 4 additions & 6 deletions components/common/MobileTokenFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,6 @@ export const MobileTokenFilters: FC<Props> = ({
</Text>
{collections?.map((collection) => {
let selected = collection?.collection?.id == filterCollection

const collectionImage = useMemo(() => {
return optimizeImage(collection?.collection?.image as string, 250)
}, [collection?.collection?.image])

return (
<Flex
key={collection?.collection?.id}
Expand Down Expand Up @@ -177,7 +172,10 @@ export const MobileTokenFilters: FC<Props> = ({
aspectRatio: '1/1',
}}
loader={({ src }) => src}
src={collectionImage}
src={optimizeImage(
collection?.collection?.image as string,
250
)}
alt={collection?.collection?.name as string}
width={24}
height={24}
Expand Down
9 changes: 4 additions & 5 deletions components/common/TokenFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ export const TokenFilters: FC<Props> = ({
{collections?.map((collection) => {
let selected = collection?.collection?.id == filterCollection

const collectionImage = useMemo(() => {
return optimizeImage(collection?.collection?.image as string, 250)
}, [collection?.collection?.image])

return (
<Flex
key={collection?.collection?.id}
Expand Down Expand Up @@ -103,7 +99,10 @@ export const TokenFilters: FC<Props> = ({
aspectRatio: '1/1',
}}
loader={({ src }) => src}
src={collectionImage}
src={optimizeImage(
collection?.collection?.image as string,
250
)}
alt={collection?.collection?.name as string}
width={24}
height={24}
Expand Down
2 changes: 1 addition & 1 deletion components/portfolio/PortfolioTokenCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export default ({
>
<Flex css={{ mb: '$4' }} align="center" justify="between">
<Flex align="center" css={{ gap: '$2', minWidth: 0 }}>
{token?.token?.collection?.imageUrl ? (
{collectionImage ? (
<Image
style={{
borderRadius: '4px',
Expand Down
6 changes: 1 addition & 5 deletions components/rankings/CollectionRankingsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,11 @@ const RankingsTableRow: FC<RankingsTableRowProps> = ({
}}
>
{collection?.sampleImages?.map((image, i) => {
const optimizedImage: string = useMemo(() => {
return optimizeImage(image, 250)
}, [image])

if (image) {
return (
<img
key={image + i}
src={optimizedImage}
src={optimizeImage(image, 250)}
style={{
borderRadius: 8,
width: 56,
Expand Down
2 changes: 1 addition & 1 deletion utils/optimizeImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ const optimizeImage = (imageHref: string | undefined, width: number) => {
} catch (e) {
console.warn('Failed to optimize image', e)
}
return imageHref
return imageHref ? imageHref : ''
}
export default optimizeImage

2 comments on commit c493ff6

@vercel
Copy link

@vercel vercel bot commented on c493ff6 Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on c493ff6 Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

artblocks-v2 – ./

artblocks-v2-unevenlabs.vercel.app
artblocks-v2-git-main-unevenlabs.vercel.app
artblocks-v2.vercel.app

Please sign in to comment.