Skip to content

Instantly share code, notes, and snippets.

@vijaycs85
Created April 24, 2015 09:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vijaycs85/cdde2d083ad731cd7de8 to your computer and use it in GitHub Desktop.
Save vijaycs85/cdde2d083ad731cd7de8 to your computer and use it in GitHub Desktop.
<?php
$file = field_file_load($data->node_data_field_media_file_field_media_file_fid);
$file_info = image_get_info($file['filepath']);
if ($file_info) {
$bytes = $file_info['file_size'];
$s = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
$e = floor(log($bytes)/log(1024));
print sprintf('%.2f '.$s[$e], ($bytes/pow(1024, floor($e))));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment