Skip to content

Commit 5ecee3f

Browse files
authored
fix(upload): ensure only image files are read for preview (#9562)
### What? Ensure only image files are read for preview. ### Why? Upon uploading larger files, it crashes the browser as it's reading the whole file for preview. Fixes #9559 Co-authored-by: Kapil Barad <>
1 parent a09fefa commit 5ecee3f

File tree

1 file changed

+1
-1
lines changed
  • packages/payload/src/admin/components/views/collections/Edit/Upload

1 file changed

+1
-1
lines changed

packages/payload/src/admin/components/views/collections/Edit/Upload/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const Upload: React.FC<Props> = (props) => {
7474

7575
const handleFileChange = useCallback(
7676
(newFile: File) => {
77-
if (newFile instanceof File) {
77+
if (newFile instanceof File && isImage(newFile.type)) {
7878
const fileReader = new FileReader()
7979
fileReader.onload = (e) => {
8080
const imgSrc = e.target?.result

0 commit comments

Comments
 (0)