function FileSize::viewElements
Same name in other branches
- 8.9.x core/modules/file/src/Plugin/Field/FieldFormatter/FileSize.php \Drupal\file\Plugin\Field\FieldFormatter\FileSize::viewElements()
- 10 core/modules/file/src/Plugin/Field/FieldFormatter/FileSize.php \Drupal\file\Plugin\Field\FieldFormatter\FileSize::viewElements()
- 11.x core/modules/file/src/Plugin/Field/FieldFormatter/FileSize.php \Drupal\file\Plugin\Field\FieldFormatter\FileSize::viewElements()
Overrides FormatterInterface::viewElements
File
-
core/
modules/ file/ src/ Plugin/ Field/ FieldFormatter/ FileSize.php, line 32
Class
- FileSize
- Formatter that shows the file size in a human readable way.
Namespace
Drupal\file\Plugin\Field\FieldFormatterCode
public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = [];
foreach ($items as $delta => $item) {
$elements[$delta] = [
'#markup' => format_size($item->value),
];
}
return $elements;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.