From 41bf79232da74ef6a2c87c5e56cd55c8112dc348 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 25 Nov 2020 16:49:43 +0100 Subject: [PATCH] Add max image size in the upload error message in whiteboard #563 --- www/whiteboard/inner.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/www/whiteboard/inner.js b/www/whiteboard/inner.js index 44efd1421..bab1603dc 100644 --- a/www/whiteboard/inner.js +++ b/www/whiteboard/inner.js @@ -331,10 +331,11 @@ define([ APP.FM.handleFile(blob); }); }; + var MAX_IMAGE_SIZE = 1 * 1024 * 1024; // 1 MB + var maxSizeStr = Messages._getKey('formattedMB', [Util.bytesToMegabytes(MAX_IMAGE_SIZE)]); var addImageToCanvas = function (img) { - // 1 MB maximum - if (img.src && img.src.length > 1 * 1024 * 1024) { - UI.warn(Messages.upload_tooLargeBrief); + if (img.src && img.src.length > MAX_IMAGE_SIZE) { + UI.warn(Messages._getKey('upload_tooLargeBrief', [maxSizeStr])); // XXX update key return; } var w = img.width; @@ -356,8 +357,8 @@ define([ var file = e.target.files[0]; var reader = new FileReader(); // 1 MB maximum - if (file.size > 1 * 1024 * 1024) { - UI.warn(Messages.upload_tooLargeBrief); + if (file.size > MAX_IMAGE_SIZE) { + UI.warn(Messages._getKey('upload_tooLargeBrief', [maxSizeStr])); return; } reader.onload = function () {