// Filesizes
// Format filesize
// -- http://stackoverflow.com/questions/2510434/format-bytes-to-kilobytes-megabytes-gigabytes
function formatBytes($size, $precision = 2)
{
$base = log($size, 1024);
$suffixes = array('', 'K', 'MB', 'G', 'T');
return round(pow(1024, $base - floor($base)), $precision) .''. $suffixes[floor($base)];
}
<?php
// usage
// $filesize = filesize( get_attached_file( $file['id']) );
// echo formatBytes($filesize);
?>