mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-08-03 15:11:40 +00:00
Show file sizes with an B for byte unit, Use an lowercase for k fo kilo and added an whitespace between number and unit
This commit is contained in:
parent
86fcafe47d
commit
24c5a92e46
1 changed files with 3 additions and 3 deletions
|
|
@ -155,9 +155,9 @@ class AttachmentManager
|
|||
//Format filesize for human reading
|
||||
//Taken from: https://www.php.net/manual/de/function.filesize.php#106569 and slightly modified
|
||||
|
||||
$sz = 'BKMGTP';
|
||||
$sz = 'BkMGTP';
|
||||
$factor = min((int) floor((strlen((string) $bytes) - 1) / 3), strlen($sz) - 1);
|
||||
//Use real (10 based) SI prefixes
|
||||
return sprintf("%.{$decimals}f", $bytes / 1000 ** $factor).$sz[$factor];
|
||||
//Use real (10 based) SI prefixes, and add a non-breaking space between the number and the unit, so that the unit is not separated from the number when wrapping text.
|
||||
return sprintf("%.{$decimals}f\u{00A0}", $bytes / 1000 ** $factor).$sz[$factor] . 'B';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue