WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 2 years ago

#31350 new defect (bug)

size_format() Displaying Incorrect Unit

Reported by: brashell Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.1
Component: General Keywords:
Focuses: Cc:
PR Number:

Description (last modified by SergeyBiryukov)

The size_format() function is using binary standards for displaying a human readable version of the file size, shouldn’t we use the IEC standard of KiB, MiB etc for the unit, or convert to SI and use 1000 instead of 1024 as the value of bytes in a kB etc (ref: http://en.wikipedia.org/wiki/Kilobyte)? It was even noted that it was technically incorrect in the comments of the function: https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/functions.php#L194 (If we do fix it, we need to take into consideration the whitespace in front of the 'B ' fixed in: [31052])

Change History (4)

#1 @brashell
5 years ago

Changeset [31052], ticket #30908

Last edited 5 years ago by SergeyBiryukov (previous) (diff)

#2 @SergeyBiryukov
5 years ago

  • Description modified (diff)

#3 @dd32
5 years ago

I vaguely recall this coming up in the past, but couldn't find any tickets for it.

Some history of the KB vs KiB debate is in Wikipedia: http://en.wikipedia.org/wiki/Mebibyte#Definition which shows that until 2009/2010ish all major OS's displayed 1024B as 1KB, completely ignoring the IEC spec, so we followed along and used what everyone expects.
However, now OS X and Ubuntu (at least) have switched to using 1000B = 1KB, leaving Microsoft the hold-out of ignoring the IEC standard.

This is so minor that it can go either way to me, but if we do change anything, we should replace 1024 with 1000, just so we never have to display 'KiB' since that's even more unfamiliar to people. I doubt anyone would notice or complain that their website says the file is 2% larger than it really is, especially not with the filesizes most people upload.

#4 @Otto42
2 years ago

At least one case exists where a user assumed that their images were being compressed on upload because of the displayed filesize difference between the reading in the Media Library vs. what their OS is telling them:

https://wordpress.org/support/topic/stop-wp-compressing-images-to-90-on-uploading-to-media-library

Last edited 2 years ago by Otto42 (previous) (diff)
Note: See TracTickets for help on using tickets.