function format_size in Drupal 4
Same name and namespace in other branches
- 8 core/includes/common.inc \format_size()
- 5 includes/common.inc \format_size()
- 6 includes/common.inc \format_size()
- 7 includes/common.inc \format_size()
- 9 core/includes/common.inc \format_size()
Generate a string representation for the given byte count.
Parameters
$size: The size in bytes.
Return value
A translated string representation of the size.
Related topics
3 calls to format_size()
- theme_upload_attachments in modules/
upload.module - Displays file attachments in table
- _upload_form in modules/
upload.module - _upload_validate in modules/
upload.module
File
- includes/
common.inc, line 849 - Common functions that many Drupal modules will need to reference.
Code
function format_size($size) {
$suffix = t('bytes');
if ($size >= 1024) {
$size = round($size / 1024, 2);
$suffix = t('KB');
}
if ($size >= 1024) {
$size = round($size / 1024, 2);
$suffix = t('MB');
}
return t('%size %suffix', array(
'%size' => $size,
'%suffix' => $suffix,
));
}