function format_size

×

Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
cis7 common.inc format_size($size, $langcode = NULL)
cle7 common.inc format_size($size, $langcode = NULL)
elmsmedia7 common.inc format_size($size, $langcode = NULL)
icor7 common.inc format_size($size, $langcode = NULL)
meedjum_blog7 common.inc format_size($size, $langcode = NULL)
mooc7 common.inc format_size($size, $langcode = NULL)

Generates a string representation for the given byte count.

Parameters

$size: A size in bytes.

$langcode: Optional language code to translate to a language other than what is used to display the page.

Return value

A translated string representation of the size.

Related topics

34 calls to format_size()
apc_requirements in sites/all/modules/ulmus/apc/apc.install
Implements hook_requirements().
backup_migrate_destination_email::save_file in sites/all/modules/ulmus/backup_migrate/includes/destinations.email.inc
Save to (ie. email the file) to the email destination.
backup_migrate_drush_destination_files in sites/all/modules/ulmus/backup_migrate/includes/backup_migrate.drush.inc
Get a list of files in a given destination
backup_migrate_ui_destination_display_files in sites/all/modules/ulmus/backup_migrate/includes/destinations.inc
List the backup files in the given destination.
backup_migrate_ui_manual_restore_form in sites/all/modules/ulmus/backup_migrate/backup_migrate.module
The restore/import upload form.

... See full list

File

includes/common.inc, line 1866
Common functions that many Drupal modules will need to reference.

Code

function format_size($size, $langcode = NULL) {
  if ($size < DRUPAL_KILOBYTE) {
    return format_plural($size, '1 byte', '@count bytes', array(), array('langcode' => $langcode));
  }
  else {
    $size = $size / DRUPAL_KILOBYTE; // Convert bytes to kilobytes.
    $units = array(
      t('@size KB', array(), array('langcode' => $langcode)),
      t('@size MB', array(), array('langcode' => $langcode)),
      t('@size GB', array(), array('langcode' => $langcode)),
      t('@size TB', array(), array('langcode' => $langcode)),
      t('@size PB', array(), array('langcode' => $langcode)),
      t('@size EB', array(), array('langcode' => $langcode)),
      t('@size ZB', array(), array('langcode' => $langcode)),
      t('@size YB', array(), array('langcode' => $langcode)),
    );
    foreach ($units as $unit) {
      if (round($size, 2) >= DRUPAL_KILOBYTE) {
        $size = $size / DRUPAL_KILOBYTE;
      }
      else {
        break;
      }
    }
    return str_replace('@size', round($size, 2), $unit);
  }
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.