private function ManageFilesForm::formatFilesize in Minify JS 8.2
Helper function to format the filesize.
Parameters
int $size: The size in bytes.
Return value
string|int The converted size string or 0.
2 calls to ManageFilesForm::formatFilesize()
- ManageFilesForm::buildForm in src/
Form/ ManageFilesForm.php - Form constructor.
- ManageFilesForm::minifiedFilesize in src/
Form/ ManageFilesForm.php - Helper function to format the minified filesize.
File
- src/
Form/ ManageFilesForm.php, line 291
Class
- ManageFilesForm
- Manage files form class.
Namespace
Drupal\minifyjs\FormCode
private function formatFilesize($size) {
if ($size) {
$suffixes = [
'',
'k',
'M',
'G',
'T',
];
$base = log($size) / log(1024);
$base_floor = floor($base);
return round(pow(1024, $base - $base_floor), 2) . $suffixes[$base_floor];
}
return 0;
}