diff --git a/app/views/avatar/_avatar_form.html.erb b/app/views/avatar/_avatar_form.html.erb
index 272397c62..a880f32aa 100644
--- a/app/views/avatar/_avatar_form.html.erb
+++ b/app/views/avatar/_avatar_form.html.erb
@@ -45,6 +45,7 @@
<%= l(:button_upload_photo) %>
+
<%= file_field_tag 'avatar[image]',
:id => nil,
@@ -57,6 +58,8 @@
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
+ :file_type => Redmine::Configuration['pic_types'].to_s,
+ :type_support_message => l(:error_pic_type),
:upload_path => upload_avatar_path(:format => 'js'),
:description_placeholder => nil ,# l(:label_optional_description)
:source_type => source.class.to_s,
diff --git a/config/configuration.yml b/config/configuration.yml
index a98ea3391..4bdd279aa 100644
--- a/config/configuration.yml
+++ b/config/configuration.yml
@@ -199,6 +199,7 @@ default:
# Maximum number of simultaneous AJAX uploads
#max_concurrent_ajax_uploads: 2
+ #pic_types: "bmp,jpeg,jpg,png,gif"
# specific configuration options for production environment
# that overrides the default ones
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index 1b3774d65..716889bbc 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -1217,6 +1217,7 @@ zh:
button_export: 导出
label_export_options: "%{export_format} 导出选项"
error_attachment_too_big: 该文件无法上传。超过文件大小限制 (%{max_size})
+ error_pic_type: "仅支持如下图片格式:"
notice_failed_to_save_time_entries: "无法保存下列所选取的 %{total} 个项目中的 %{count} 工时: %{ids}。"
label_x_issues:
zero: 0 问题
diff --git a/lib/redmine/configuration.rb b/lib/redmine/configuration.rb
index 6723b777e..ba8e91294 100644
--- a/lib/redmine/configuration.rb
+++ b/lib/redmine/configuration.rb
@@ -21,7 +21,8 @@ module Redmine
# Configuration default values
@defaults = {
'email_delivery' => nil,
- 'max_concurrent_ajax_uploads' => 2
+ 'max_concurrent_ajax_uploads' => 2,
+ 'pic_types' => "bmp,jpeg,jpg,png,gif"
}
@config = nil
diff --git a/public/javascripts/avatars.js b/public/javascripts/avatars.js
index 24bc1ee1c..db9a2255e 100644
--- a/public/javascripts/avatars.js
+++ b/public/javascripts/avatars.js
@@ -140,10 +140,34 @@ function uploadAndAttachFiles(files, inputEl) {
if (sizeExceeded) {
window.alert(maxFileSizeExceeded);
} else {
- $.each(files, function() {addFile(inputEl, this, true);});
+ uploadAndTypeFiles(files,inputEl);
+ //$.each(files, function() {addFile(inputEl, this, true);});
}
}
+function uploadAndTypeFiles(files, inputEl) {
+
+ var enableType = $(inputEl).data('file-type');
+ var typeSupportrdMessage = $(inputEl).data('type-support-message');
+ if (enableType == null || enableType.trim() == "")
+ {
+ $.each(files, function() {addFile(inputEl, this, true);});
+ return;
+ }
+ var typeSupported = false;
+ $.each(files, function() {
+ var a = this.name.split('.');
+ var type = a[a.length-1];
+ var rs = enableType.indexOf(type);
+ if(rs >= 0) {typeSupported = true }
+ });
+ if (typeSupported) {
+ $.each(files, function() {addFile(inputEl, this, true);});
+ } else {
+ window.alert(typeSupportrdMessage + enableType);
+ }
+}
+
function handleFileDropEvent(e) {
$(this).removeClass('fileover');