# Show image file size limit on user#preference page

**URL:** https://meta.discourse.org/t/show-image-file-size-limit-on-user-preference-page/41707
**Category:** UX
**Created:** [March 29, 2016, 11:34am UTC](https://meta.discourse.org/t/show-image-file-size-limit-on-user-preference-page/41707 "2016-03-29T11:34:10Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![saiqulhaq](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/saiqulhaq/32/119871_2.png) [@saiqulhaq](https://meta.discourse.org/u/saiqulhaq)
#### Post date: [March 29, 2016, 11:34am UTC](https://meta.discourse.org/t/show-image-file-size-limit-on-user-preference-page/41707/1 "2016-03-29T11:34:10Z")

</div>

## The problem is when I am trying to upload large image, there is no information regarding the file size limit of uploaded image. Please take a look at following screenshot ![](https://global.discourse-cdn.com/meta/original/3X/b/2/b2d812400e339565dcb59f593b1f405f83090fcb.png)

 ![](https://global.discourse-cdn.com/meta/original/3X/2/c/2cb69a616ace40cb773ba2fe1dca38b92aca23d1.png)

In my country the internet connection is very bad, the upload speed is very slow, so if I’m trying to upload 10MB image, it could take 2-3 minutes to complete, then Discourse give me the error alert when the uploading is finished ☹

I’ve checked the code that Discourse optimize the uploaded image until reach SiteSetting.max\_image\_size\_kb value, otherwise it can’t save the image

Any idea how this could be solved?  
Actually I would like to send pull request to add more message on each instructions, but I’m not convince that it will be accepted

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [March 29, 2016, 12:42pm UTC](https://meta.discourse.org/t/show-image-file-size-limit-on-user-preference-page/41707/2 "2016-03-29T12:42:06Z")

</div>

We don’t test for file size on the client-side since we now automagically try to downsize large images.

> [@saiqulhaq](#):
>
> Actually I would like to send pull request to add more message on each instructions, but I’m not convince that it will be accepted

Sure, I support adding the maximum image size in the instructions.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [April 11, 2016, 9:34am UTC](https://meta.discourse.org/t/show-image-file-size-limit-on-user-preference-page/41707/3 "2016-04-11T09:34:50Z")

</div>

OK so the root issue is that we can’t tell you that your file was rejected until after it is uploaded.

But: if you are operating from a place with terrible bandwidth, why would you upload a very large image to start with? That doesn’t make sense to me.

I appreciate the contribution, but I feel this is not the correct solution, and it adds a fair bit of code and new translations, and does not address the root problem at all: you don’t know that your upload was rejected until _after_ you upload it.

The types of users that will get this wrong, are unlikely to click a “read more” in my opinion.

---

<div class="post-metadata">

### Author: ![saiqulhaq](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/saiqulhaq/32/119871_2.png) [@saiqulhaq](https://meta.discourse.org/u/saiqulhaq)
#### Post date: [April 11, 2016, 10:06am UTC](https://meta.discourse.org/t/show-image-file-size-limit-on-user-preference-page/41707/4 "2016-04-11T10:06:43Z")

</div>

I have planned to add information in simple text format, but I want to make  
it reusable in other functions, so that’s why the UI is like clickable  
format and add more code

I’m thinking another solution for this problem

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [April 12, 2016, 1:30am UTC](https://meta.discourse.org/t/show-image-file-size-limit-on-user-preference-page/41707/5 "2016-04-12T01:30:20Z")

</div>

Wait, is there any reason a simple

> (max: 10MB)

wouldn’t do?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [April 12, 2016, 1:32am UTC](https://meta.discourse.org/t/show-image-file-size-limit-on-user-preference-page/41707/6 "2016-04-12T01:32:09Z")

</div>

It wouldn’t but it still feels like trivia for the sake of trivia. Do Twitter or Facebook print a max next to their image upload controls for profiles? I doubt it.

---

<div class="post-metadata">

### Author: ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)
#### Post date: [April 12, 2016, 1:42am UTC](https://meta.discourse.org/t/show-image-file-size-limit-on-user-preference-page/41707/7 "2016-04-12T01:42:52Z")

</div>

> [@codinghorror](#):
>
> Do Twitter or Facebook print a max next to their image upload controls for profiles?

Checked via desktop sites…  
No, they don’t - simply selecting “upload” shows a file dialog.  
They don’t show any size indicator for profile pictures nor images, simply an upload link / button.

---

<div class="post-metadata">

### Author: ![saiqulhaq](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/saiqulhaq/32/119871_2.png) [@saiqulhaq](https://meta.discourse.org/u/saiqulhaq)
#### Post date: [April 12, 2016, 5:44am UTC](https://meta.discourse.org/t/show-image-file-size-limit-on-user-preference-page/41707/8 "2016-04-12T05:44:56Z")

</div>

Maybe because they don’t give limitation to the file size of uploaded image

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [April 12, 2016, 6:17am UTC](https://meta.discourse.org/t/show-image-file-size-limit-on-user-preference-page/41707/9 "2016-04-12T06:17:01Z")

</div>

Are you sure? Did you try uploading a 20mb image there?

---

<div class="post-metadata">

### Author: ![saiqulhaq](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/saiqulhaq/32/119871_2.png) [@saiqulhaq](https://meta.discourse.org/u/saiqulhaq)
#### Post date: [April 12, 2016, 7:29am UTC](https://meta.discourse.org/t/show-image-file-size-limit-on-user-preference-page/41707/10 "2016-04-12T07:29:23Z")

</div>

I just uploaded an image with size 26,588,644 bytes (26.6 MB on disk) and succeed.  
I also just found [this page](https://web.facebook.com/help/270699543014290), facebook says that the limit is 25MB.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [April 12, 2016, 7:32am UTC](https://meta.discourse.org/t/show-image-file-size-limit-on-user-preference-page/41707/11 "2016-04-12T07:32:06Z")

</div>

Can you try again with an image which is at least 30MB? Depending on the filesystem, the size of the file can vary slightly and a 26MB image might actually only require a bit less than 25MB on another filesystem 😉

(_They might be automatically downsizing images too_)

---

<div class="post-metadata">

### Author: ![saiqulhaq](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/saiqulhaq/32/119871_2.png) [@saiqulhaq](https://meta.discourse.org/u/saiqulhaq)
#### Post date: [April 12, 2016, 2:17pm UTC](https://meta.discourse.org/t/show-image-file-size-limit-on-user-preference-page/41707/12 "2016-04-12T14:17:39Z")

</div>

I just uploaded an image from [this page](http://visibleearth.nasa.gov/view.php?id=73726), I picked world.topo.bathy.200406.3x21600x21600.C1.jpg image, they say that is 36 MB, but on my laptop the size is 88,661,060 bytes (88.7 MB on disk), however the result is succeed, it’s on my fb

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [April 12, 2016, 2:19pm UTC](https://meta.discourse.org/t/show-image-file-size-limit-on-user-preference-page/41707/13 "2016-04-12T14:19:04Z")

</div>

So they don’t actually enforce a limit. Interesting 🤔

_Thanks for doing the work_.

---

<div class="post-metadata">

### Author: ![pinbot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pinbot/32/61332_2.png) [@pinbot](https://meta.discourse.org/u/pinbot)
#### Post date: [August 31, 2016, 9:07am UTC](https://meta.discourse.org/t/show-image-file-size-limit-on-user-preference-page/41707/14 "2016-08-31T09:07:04Z")

</div>

It makes sense mentioning the file size limit . A forum is not like facebook , twitter in many way

---

<div class="post-metadata">

### Author: ![saiqulhaq](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/saiqulhaq/32/119871_2.png) [@saiqulhaq](https://meta.discourse.org/u/saiqulhaq)
#### Post date: [September 3, 2016, 1:15am UTC](https://meta.discourse.org/t/show-image-file-size-limit-on-user-preference-page/41707/15 "2016-09-03T01:15:49Z")

</div>

yes agreeed  
but sometimes Discourse’s image compressor able to compress the image file  
into significant smaller size  
e.g.: the file size limit is 10MB, and an user uploaded 15 MB image, then  
validation status will depend on image compressor, is it succeeds or not to  
compress the image until under 10MB

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [September 3, 2016, 1:49am UTC](https://meta.discourse.org/t/show-image-file-size-limit-on-user-preference-page/41707/16 "2016-09-03T01:49:55Z")

</div>

This issue is very real in my community. What is odd is that people in low bandwidth countries often try to upload a big file to discourse, it fails, then they email it to me using Gmail and ask me to post it for them. I then resize it myself before uploading and it works. Go figure.

So maybe Gmail has a more failsafe upload system for large files?

Is there no way to have the client check the file size and complain if it is big, eg more than 1mb, then give a warning before proceeding?

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [September 3, 2016, 2:22am UTC](https://meta.discourse.org/t/show-image-file-size-limit-on-user-preference-page/41707/17 "2016-09-03T02:22:02Z")

</div>

> [@tobiaseigen](#):
>
> Is there no way to have the client check the file size and complain if it is big, eg more than 1mb even, then give a warning before proceeding?

There is the HTML5 File API eg. from

> **[Using files from web applications - Web APIs | MDN](https://developer.mozilla.org/en-US/docs/Web/API/File_API/Using_files_from_web_applications)**
>
> Using the File API, web content can ask the user to select local files and then read the contents of those files. This selection can be done by either using an HTML element or by drag and drop.

```plaintext
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>File(s) size</title>
<script>
function updateSize() {
  var nBytes = 0,
      oFiles = document.getElementById("uploadInput").files,
      nFiles = oFiles.length;
  for (var nFileId = 0; nFileId < nFiles; nFileId++) {
    nBytes += oFiles[nFileId].size;
  }
  var sOutput = nBytes + " bytes";
  // optional code for multiples approximation
  for (var aMultiples = ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"], nMultiple = 0, nApprox = nBytes / 1024; nApprox > 1; nApprox /= 1024, nMultiple++) {
    sOutput = nApprox.toFixed(3) + " " + aMultiples[nMultiple] + " (" + nBytes + " bytes)";
  }
  // end of optional code
  document.getElementById("fileNum").innerHTML = nFiles;
  document.getElementById("fileSize").innerHTML = sOutput;
}
</script>
</head>

<body onload="updateSize();">
<form name="uploadForm">
<p><input id="uploadInput" type="file" name="myFiles" onchange="updateSize();" multiple> selected files: <span id="fileNum">0</span>; total size: <span id="fileSize">0</span></p>
<p><input type="submit" value="Send file"></p>
</form>
</body>
</html>

```

Not the best support, but not all that bad either

> **[Can I use... Support tables for HTML5, CSS3, etc](https://caniuse.com#feat=fileapi)**
>
> "Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.

---

<div class="post-metadata">

### Author: ![saiqulhaq](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/saiqulhaq/32/119871_2.png) [@saiqulhaq](https://meta.discourse.org/u/saiqulhaq)
#### Post date: [September 3, 2016, 6:48am UTC](https://meta.discourse.org/t/show-image-file-size-limit-on-user-preference-page/41707/18 "2016-09-03T06:48:14Z")

</div>

Hi @tobiaseigen, @Mittineague  
Please take a look at Jeff comments on my [pull request at github](https://github.com/discourse/discourse/pull/4165) regarding this issue

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [February 28, 2017, 2:26pm UTC](https://meta.discourse.org/t/show-image-file-size-limit-on-user-preference-page/41707/19 "2017-02-28T14:26:26Z")

</div>

this is back again on my site. people really struggle with this why not indicate a file size limit on the picture upload page? Or (better) sort of better error handling when a picture upgrade fails?

Here’s what people commonly see on my site. See screenshot sent to me by a member of my site.

 ![](https://global.discourse-cdn.com/meta/original/3X/c/6/c68212e32bbae485a3a52ae92b7fdcbf05cf0b23.png)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [February 28, 2017, 3:03pm UTC](https://meta.discourse.org/t/show-image-file-size-limit-on-user-preference-page/41707/20 "2017-02-28T15:03:26Z")

</div>

@zogstrip we probably want some sort of error here if people upload a gigantic avatar, can you confirm it is in place?

[Next page](https://meta.discourse.org/t/show-image-file-size-limit-on-user-preference-page/41707.md?page=2)
