max upload size message when images are too big.

This commit is contained in:
Sam 2013-03-19 00:19:05 -07:00
parent 1cd26a7dcf
commit 9805f7d2f5
4 changed files with 10 additions and 1 deletions

View File

@ -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);
}
});

View File

@ -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)

View File

@ -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?"

View File

@ -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}"