import React from "react"; import type { MediaRendererProps } from "./types"; /** * Component that renders any asset stored on IPFS (or anywhere else), given the IPFS URI / URL. * * Under the hood, the asset is fetched from IPFS through the thirdweb IPFS gateway (or just * a regular fetch if the `src` is not an IPFS URI). * The [mime type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) of the * asset is determined and the appropriate component is rendered on the UI. * * For example, if the URI points to an image, the `img` tag will be used. If it is a video, the `video` tag will be used, etc. * The component currently supports: * * - Images * - Videos * - Audio files * - 3D Models * - SVGs (for [on-chain NFTs](https://blog.thirdweb.com/guides/how-to-create-on-chain-nfts-with-thirdweb/)) * - `iframes` and `HTML` * - If none of these are appropriate, the fallback is a link to the asset * * @example * * Provide the IPFS URI (or any URL that points to media) to the `src` prop to render the asset. * * ```jsx * import { MediaRenderer } from "@thirdweb-dev/react"; * * function Home() { * return ( * // Any URL that points to media (IPFS URI, HTTP URL, etc.) * * ); * } * ``` * * @remarks * The default size of rendered media is 300px x 300px, but this can be changed using the `width` and `height` props. * * You can use `npx thirdweb upload ` to upload any file to IPFS and get the IPFS URI. * * @param props - * The props for the component * * ### src (required) * * The [src](https://www.w3schools.com/tags/att_img_src.asp) attribute specifies the URL of the media. * * This can be an IPFS URI, or any URL that points to media (e.g. HTTP URL, etc.). * * ```jsx * import { MediaRenderer } from "@thirdweb-dev/react"; * * function Home() { * return ( * * ); * } * ``` * * * ### alt (recommended) * * The [alt](https://www.w3schools.com/tags/att_img_alt.asp) attributes provides alternative * information for the media, if a user for some reason cannot view it * (due to slow connection, an error in the `src` attribute, or if the user is visually impaired). * * The default value is `""`. * * ```jsx * import { MediaRenderer } from "@thirdweb-dev/react"; * * function Home() { * return ( * // Any URL that points to media (IPFS URI, HTTP URL, etc.) * * ); * } * ``` * * * ### poster (optional) * * The [poster](https://www.w3schools.com/tags/att_video_poster.asp) is the image * that is shown before the video is played. * * The default value is the first frame of the video. * * If the `src` is not a video, this prop is ignored. * * ```jsx * import { MediaRenderer } from "@thirdweb-dev/react"; * * function Home() { * return ( * // Any URL that points to media (IPFS URI, HTTP URL, etc.) * * ); * } * ``` * * * ### controls (optional) * * Show the media controls (play, pause, etc.) for the media, where applicable. * * The default value is `false`. * * ```jsx * import { ThirdwebNftMedia } from "@thirdweb-dev/react"; * * function Home() { * // ... Get the NFT metadata * * return ( * * ); * } * ``` * * * ### height (optional) * * The height of the rendered media. * * The default value is `auto`. * * ```jsx * import { ThirdwebNftMedia } from "@thirdweb-dev/react"; * * function Home() { * // ... Get the NFT metadata * * return ( * * ); * } * ``` * * ### width (optional) * * The width of the rendered media. * * The default value is `auto`. * * ```jsx * import { ThirdwebNftMedia } from "@thirdweb-dev/react"; * * function Home() { * // ... Get the NFT metadata * * return ( * * ); * } * ``` * * * ### requireInteraction (optional) * * Require user interaction to play the media (i.e. disable autoplay). * * The default value is `false`. * * ```jsx * import { ThirdwebNftMedia } from "@thirdweb-dev/react"; * * function Home() { * // ... Get the NFT metadata * * return ( * * ); * } * ``` * * * ### className (optional) * * Apply custom CSS styles to the button using a class name. * * ```jsx * import { ThirdwebNftMedia } from "@thirdweb-dev/react"; * * function Home() { * // ... Get the NFT metadata * * return ( * * ); * } * ``` * * ### style (optional) * * Apply custom CSS styles to the button using an inline style. * * ```jsx * import { ThirdwebNftMedia } from "@thirdweb-dev/react"; * * function Home() { * // ... Get the NFT metadata * * return ( * * ); * } * ``` */ export declare const MediaRenderer: React.ForwardRefExoticComponent>; export interface MediaType { url?: string; mimeType?: string; } /** * Hook for resolving the media type and URL of a given URI (including IPFS URIs). * * The `` component renders the relevant. * HTML element for a given URL, including IPFS URIs. e.g. `` for images, `