public static function BulkUploadForm::bytesToString in Lightning Media 8
Same name and namespace in other branches
- 8.4 modules/lightning_media_bulk_upload/src/Form/BulkUploadForm.php \Drupal\lightning_media_bulk_upload\Form\BulkUploadForm::bytesToString()
- 8.2 modules/lightning_media_bulk_upload/src/Form/BulkUploadForm.php \Drupal\lightning_media_bulk_upload\Form\BulkUploadForm::bytesToString()
- 8.3 modules/lightning_media_bulk_upload/src/Form/BulkUploadForm.php \Drupal\lightning_media_bulk_upload\Form\BulkUploadForm::bytesToString()
Converts a number of bytes into a human-readable string.
Parameters
int $bytes: A number of bytes.
Return value
string The human-readable measurement, like '2 MB' or '10 GB'.
1 call to BulkUploadForm::bytesToString()
- BulkUploadForm::buildForm in modules/
lightning_media_bulk_upload/ src/ Form/ BulkUploadForm.php - Form constructor.
File
- modules/
lightning_media_bulk_upload/ src/ Form/ BulkUploadForm.php, line 101
Class
- BulkUploadForm
- A form for uploading multiple media assets at once.
Namespace
Drupal\lightning_media_bulk_upload\FormCode
public static function bytesToString($bytes) {
$units = array_map('t', [
'bytes',
'KB',
'MB',
'GB',
'TB',
]);
while ($bytes > 1024) {
$bytes /= 1024;
array_shift($units);
}
return $bytes . ' ' . reset($units);
}