overleaf-cep/services/web/frontend/js/features/file-view/components/file-view-image.tsx
Brian Gough a08d1b18dc Merge pull request #22378 from overleaf/bg-issue22368
Fix frontend to handle missing hashes for image preview

GitOrigin-RevId: e67300d9b08b02b1670cb3a7bbd4483cf4486f51
2024-12-10 09:04:29 +00:00

23 lines
533 B
TypeScript

import { useProjectContext } from '../../../shared/context/project-context'
import { BinaryFile } from '@/features/file-view/types/binary-file'
import { fileUrl } from '../../utils/fileUrl'
export default function FileViewImage({
file,
onLoad,
onError,
}: {
file: BinaryFile
onLoad: () => void
onError: () => void
}) {
const { _id: projectId } = useProjectContext()
return (
<img
src={fileUrl(projectId, file.id, file.hash)}
onLoad={onLoad}
onError={onError}
alt={file.name}
/>
)
}