Set accept attribute to image/* in ImageUpload (#989)

That way, browsers will suggest to the users to upload an image file instead of any kind of file.

The behaviour is in-line with Element's, which specifies the same attribute when selecting an avatar.

Please note that it does not prevent users from uploading non-image files as avatars, as browsers interpret that attribute as a mere suggestion, which can be bypassed in the file select dialog.

Partially fixes #982.
This commit is contained in:
Stefano Pigozzi 2023-01-15 05:14:16 +01:00 committed by GitHub
parent e5e3f5f0a3
commit 9a34daa2bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -74,7 +74,7 @@ function ImageUpload({
<Text variant="b3">{uploadPromise ? 'Cancel' : 'Remove'}</Text>
</button>
)}
<input onChange={uploadImage} style={{ display: 'none' }} ref={uploadImageRef} type="file" />
<input onChange={uploadImage} style={{ display: 'none' }} ref={uploadImageRef} type="file" accept="image/*" />
</div>
);
}