function FilemimeFormatter::viewValue
Same name in other branches
- 8.9.x core/modules/file/src/Plugin/Field/FieldFormatter/FilemimeFormatter.php \Drupal\file\Plugin\Field\FieldFormatter\FilemimeFormatter::viewValue()
- 10 core/modules/file/src/Plugin/Field/FieldFormatter/FilemimeFormatter.php \Drupal\file\Plugin\Field\FieldFormatter\FilemimeFormatter::viewValue()
- 11.x core/modules/file/src/Plugin/Field/FieldFormatter/FilemimeFormatter.php \Drupal\file\Plugin\Field\FieldFormatter\FilemimeFormatter::viewValue()
Overrides BaseFieldFileFormatterBase::viewValue
File
-
core/
modules/ file/ src/ Plugin/ Field/ FieldFormatter/ FilemimeFormatter.php, line 59
Class
- FilemimeFormatter
- Formatter to render the file MIME type, with an optional icon.
Namespace
Drupal\file\Plugin\Field\FieldFormatterCode
protected function viewValue(FieldItemInterface $item) {
$value = $item->value;
if ($this->getSetting('filemime_image') && $value) {
$file_icon = [
'#theme' => 'image__file_icon',
'#file' => $item->getEntity(),
];
return $file_icon;
}
return $value;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.