(props: StorageImageProps & React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>)
| 49 | } |
| 50 | |
| 51 | function INTERNALStorageImage(props: StorageImageProps & React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>): JSX.Element { |
| 52 | let { storage, storagePath, suspense, placeHolder, ...imgProps } = props; |
| 53 | |
| 54 | const reactfireOptions: ReactFireOptions<string> = { |
| 55 | suspense: useSuspenseEnabledFromConfigAndContext(suspense), |
| 56 | }; |
| 57 | |
| 58 | if (!storage) { |
| 59 | throw new Error('Storage was not passed to component INTERNALStorageImage. This should not be possible'); |
| 60 | } |
| 61 | |
| 62 | const { status, data: imgSrc } = useStorageDownloadURL(ref(storage, storagePath), reactfireOptions); |
| 63 | |
| 64 | if (status === 'success') { |
| 65 | if (!(imgProps.alt || imgProps.alt === '')) { |
| 66 | console.warn( |
| 67 | `No alt prop provided for StorageImage with storagePath "${storagePath}"`, |
| 68 | 'img elements must have an alt prop, either with meaningful text, or an empty string for decorative images' |
| 69 | ); |
| 70 | } |
| 71 | |
| 72 | return <img src={imgSrc} alt={imgProps.alt} {...imgProps} />; |
| 73 | } else { |
| 74 | return placeHolder ?? <>''</>; |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | export function StorageImage(props: StorageImageProps & React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>) { |
| 79 | let { storage } = props; |
nothing calls this directly
no test coverage detected