General: Return "O B" when passing 0 to size_format().

Props swissspidy.
Fixes #36635.

git-svn-id: https://develop.svn.wordpress.org/trunk@37962 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling
2016-07-05 10:35:24 +00:00
parent ce7b53fb3f
commit c259f4c35d
3 changed files with 56 additions and 22 deletions

View File

@@ -263,6 +263,10 @@ function size_format( $bytes, $decimals = 0 ) {
'B' => 1,
);
if ( 0 === $bytes ) {
return number_format_i18n( 0, $decimals ) . ' B';
}
foreach ( $quant as $unit => $mag ) {
if ( doubleval( $bytes ) >= $mag ) {
return number_format_i18n( $bytes / $mag, $decimals ) . ' ' . $unit;