function format_size
Same name in other branches
- 7.x includes/common.inc \format_size()
- 9 core/includes/common.inc \format_size()
- 8.9.x core/includes/common.inc \format_size()
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
\Drupal\Core\StringTranslation\TranslatableMarkup A translated string representation of the size.
Deprecated
in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\Core\StringTranslation\ByteSizeMarkup::create($size, $langcode) instead.
See also
https://www.drupal.org/node/2999981
Related topics
3 calls to format_size()
- FormAjaxSubscriber::formatSize in core/
lib/ Drupal/ Core/ Form/ EventSubscriber/ FormAjaxSubscriber.php - Wraps format_size()
- LegacyCommonTest::testFormatSizeDeprecation in core/
tests/ Drupal/ KernelTests/ Core/ Common/ LegacyCommonTest.php - Tests deprecation of the format_size() function.
- MigrateExecutable::formatSize in core/
modules/ migrate/ src/ MigrateExecutable.php - Generates a string representation for the given byte count.
File
-
core/
includes/ common.inc, line 141
Code
function format_size($size, $langcode = NULL) {
@trigger_error('format_size() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \\Drupal\\Core\\StringTranslation\\ByteSizeMarkup::create($size, $langcode) instead. See https://www.drupal.org/node/2999981', E_USER_DEPRECATED);
return ByteSizeMarkup::create($size ?? 0, $langcode);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.