mirror of https://github.com/zulip/zulip.git
settings ui: Restrict file type for image file pickers.
Previously, we would allow users to pick any file, even if we didn't support that file type.
This commit is contained in:
parent
64025d2ce7
commit
45c21b79e1
|
@ -4,18 +4,18 @@ var upload_widget = (function () {
|
|||
|
||||
var default_max_file_size = 5;
|
||||
|
||||
var supported_types = [
|
||||
'image/jpeg',
|
||||
'image/png',
|
||||
'image/gif',
|
||||
'image/tiff',
|
||||
];
|
||||
|
||||
function is_image_format(file) {
|
||||
var type = file.type;
|
||||
if (!type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var supported_types = [
|
||||
'image/jpeg',
|
||||
'image/png',
|
||||
'image/gif',
|
||||
'image/tiff',
|
||||
];
|
||||
return _.indexOf(supported_types, type) >= 0;
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,7 @@ var upload_widget = (function () {
|
|||
return false;
|
||||
});
|
||||
|
||||
get_file_input().attr('accept', supported_types.toString());
|
||||
get_file_input().on('change', function (e) {
|
||||
if (e.target.files.length === 0) {
|
||||
input_error.hide();
|
||||
|
@ -136,6 +137,7 @@ var upload_widget = (function () {
|
|||
return false;
|
||||
});
|
||||
|
||||
get_file_input().attr('accept', supported_types.toString());
|
||||
get_file_input().on('change', function (e) {
|
||||
if (e.target.files.length === 0) {
|
||||
input_error.hide();
|
||||
|
|
Loading…
Reference in New Issue