diff --git a/app/assets/javascripts/discourse/views/composer_view.js b/app/assets/javascripts/discourse/views/composer_view.js index 14b1a4d5f8b..d36445af564 100644 --- a/app/assets/javascripts/discourse/views/composer_view.js +++ b/app/assets/javascripts/discourse/views/composer_view.js @@ -305,7 +305,12 @@ Discourse.ComposerView = Discourse.View.extend({ return _this.addMarkdown(html); }, fail: function(e, data) { - bootbox.alert(Em.String.i18n('post.errors.upload')); + // 413 == entity too large, returned usually from nginx + if(data.jqXHR && data.jqXHR.status === 413) { + bootbox.alert(Em.String.i18n('post.errors.upload_too_large', {max_size_kb: Discourse.SiteSettings.max_upload_size_kb})); + } else { + bootbox.alert(Em.String.i18n('post.errors.upload')); + } return _this.set('loadingImage', false); } }); diff --git a/app/models/site_setting.rb b/app/models/site_setting.rb index 6246a4a219d..3015f343bdc 100644 --- a/app/models/site_setting.rb +++ b/app/models/site_setting.rb @@ -39,6 +39,8 @@ class SiteSetting < ActiveRecord::Base # cf. https://github.com/discourse/discourse/pull/462#issuecomment-14991562 client_setting(:category_colors, 'BF1E2E|F1592A|F7941D|9EB83B|3AB54A|12A89D|25AAE2|0E76BD|652D90|92278F|ED207B|8C6238|231F20|808281|B3B5B4|283890') + client_setting(:max_upload_size_kb, 1024) + # settings only available server side setting(:auto_track_topics_after, 300000) setting(:new_topic_duration_minutes, 60 * 48) diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 381c2254d92..4cd07acb2b2 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -538,6 +538,7 @@ en: create: "Sorry, there was an error creating your post. Please try again." edit: "Sorry, there was an error editing your post. Please try again." upload: "Sorry, there was an error uploading that file. Please try again." + upload_too_large: "Sorry, the file you are trying to upload is too big (maximum size is {{max_size_kb}}kb), please resize it and try again." abandon: "Are you sure you want to abandon your post?" diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 8e4a65f0c29..df313efa325 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -424,6 +424,7 @@ en: min_body_similar_length: "The minimum length of a post's body before it will be checked for similar topics" category_colors: "A pipe (|) separated list of hexadecimal color values allowed for categories" + max_upload_size_kb: "The maximum size of files we allow users to upload in kb - be sure to configure the limit in nginx (client_max_body_size) / apache or proxy as well." notification_types: mentioned: "%{display_username} mentioned you in %{link}"