Show upload file size in upload browser. Props tellyworth. fixes #4561

git-svn-id: https://develop.svn.wordpress.org/trunk@5801 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2007-07-15 17:52:50 +00:00
parent f952fd8ac5
commit 4c70bb896e
2 changed files with 19 additions and 1 deletions
+16
View File
@@ -91,6 +91,22 @@ function number_format_i18n($number, $decimals = null) {
return number_format($number, $decimals, $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep']);
}
function size_format($bytes, $decimals = null) {
// technically the correct unit names for powers of 1024 are KiB, MiB etc
// see http://en.wikipedia.org/wiki/Byte
$quant = array(
'TB' => pow(1024, 4),
'GB' => pow(1024, 3),
'MB' => pow(1024, 2),
'kB' => pow(1024, 1),
'B' => pow(1024, 0),
);
foreach ($quant as $unit => $mag)
if ( intval($bytes) >= $mag )
return number_format_i18n($bytes / $mag, $decimals) . ' ' . $unit;
}
function get_weekstartend($mysqlstring, $start_of_week) {
$my = substr($mysqlstring,0,4);
$mm = substr($mysqlstring,8,2);