Files
explore/ui/shared/nft/useLoadImageViaIpfs.tsx
0890eb286a Improvements for NFT media (#2643)
* Show NFT image for token transfers

Fixes #2547

* rewrite logic of loading NFT media

* make amends to NftEntity

* show original media size only in the modal

* immutable envs

* tests

* fix fallback condition

* fixes

* fix one more test

* Removing blockscout-ci-cd from helm repo

---------

Co-authored-by: Nick Zenchik <[email protected]>
2025-03-25 13:53:27 +01:00

17 lines
431 B
TypeScript

import { verifiedFetch } from '@helia/verified-fetch';
import React from 'react';
export default function useLoadImageViaIpfs() {
return React.useCallback(async(url: string) => {
const response = await verifiedFetch(url);
if (response.status !== 200) {
throw new Error('Failed to load image');
}
const blob = await response.blob();
const src = URL.createObjectURL(blob);
return src;
}, [ ]);
}