Update attachment size limits to match mobile clients
Per WhisperSystems/TextSecure@8a1428e, bump GIF limit to 5MB, and audio/video limit to 100MB. Update toast to notify in correct human-readable units. The only kB size limit is for images, and will trigger only if after scaling up to 4 times, the rescaled image did not come in under the size limit without unacceptable quality loss. Closes #354
This commit is contained in:
parent
b9b01330fe
commit
861bc416e6
2 changed files with 19 additions and 6 deletions
|
@ -135,7 +135,7 @@
|
||||||
</script>
|
</script>
|
||||||
<script type='text/x-tmpl-mustache' id='file-size-modal'>
|
<script type='text/x-tmpl-mustache' id='file-size-modal'>
|
||||||
Sorry, the selected file exceeds message size
|
Sorry, the selected file exceeds message size
|
||||||
restrictions. ({{ limit }}kB)
|
restrictions. ({{ limit }}{{ units }})
|
||||||
</script>
|
</script>
|
||||||
<script type='text/x-tmpl-mustache' id='message-detail'>
|
<script type='text/x-tmpl-mustache' id='message-detail'>
|
||||||
<div class='conversation-header'>
|
<div class='conversation-header'>
|
||||||
|
|
|
@ -113,14 +113,27 @@
|
||||||
|
|
||||||
this.autoScale(file).then(function(blob) {
|
this.autoScale(file).then(function(blob) {
|
||||||
var limitKb = 1000000;
|
var limitKb = 1000000;
|
||||||
switch (type) {
|
var blobType = file.type === 'image/gif' ? 'gif' : type;
|
||||||
case 'image': limitKb = 420; break;
|
switch (blobType) {
|
||||||
case 'audio': limitKb = 32000; break;
|
case 'image':
|
||||||
case 'video': limitKb = 8000; break;
|
limitKb = 420; break;
|
||||||
|
case 'gif':
|
||||||
|
limitKb = 5000; break;
|
||||||
|
case 'audio':
|
||||||
|
limitKb = 100000; break;
|
||||||
|
case 'video':
|
||||||
|
limitKb = 100000; break;
|
||||||
}
|
}
|
||||||
if ((blob.size/1024).toFixed(4) >= limitKb) {
|
if ((blob.size/1024).toFixed(4) >= limitKb) {
|
||||||
|
var units = ['kB','MB','GB'];
|
||||||
|
var u = -1;
|
||||||
|
var limit = limitKb * 1000;
|
||||||
|
do {
|
||||||
|
limit /= 1000;
|
||||||
|
++u;
|
||||||
|
} while (limit >= 1000 && u < units.length - 1);
|
||||||
var toast = new Whisper.FileSizeToast({
|
var toast = new Whisper.FileSizeToast({
|
||||||
model: {limit: limitKb}
|
model: {limit: limit, units: units[u]}
|
||||||
});
|
});
|
||||||
toast.$el.insertAfter(this.$el);
|
toast.$el.insertAfter(this.$el);
|
||||||
toast.render();
|
toast.render();
|
||||||
|
|
Loading…
Reference in a new issue