format_size
- Versions
- 4.6 – 5
format_size($size)- 6 – 7
format_size($size, $langcode = NULL)
Generate a string representation for the given byte count.
Parameters
$size A size in bytes.
$langcode Optional language code to translate to a language other than what is used to display the page.
Return value
A translated string representation of the size.
Related topics
Code
includes/common.inc, line 1231
<?php
function format_size($size, $langcode = NULL) {
if ($size < 1024) {
return format_plural($size, '1 byte', '@count bytes', array(), $langcode);
}
else {
$size = round($size / 1024, 2);
$suffix = t('KB', array(), $langcode);
if ($size >= 1024) {
$size = round($size / 1024, 2);
$suffix = t('MB', array(), $langcode);
}
return t('@size @suffix', array('@size' => $size, '@suffix' => $suffix), $langcode);
}
}
?>Login or register to post comments 