protected function FileMediaFormatterBase::prepareAttributes in Drupal 10
Same name and namespace in other branches
- 8 core/modules/file/src/Plugin/Field/FieldFormatter/FileMediaFormatterBase.php \Drupal\file\Plugin\Field\FieldFormatter\FileMediaFormatterBase::prepareAttributes()
- 9 core/modules/file/src/Plugin/Field/FieldFormatter/FileMediaFormatterBase.php \Drupal\file\Plugin\Field\FieldFormatter\FileMediaFormatterBase::prepareAttributes()
Prepare the attributes according to the settings.
Parameters
string[] $additional_attributes: Additional attributes to be applied to the HTML element. Attribute names will be used as key and value in the HTML element.
Return value
\Drupal\Core\Template\Attribute Container with all the attributes for the HTML tag.
2 calls to FileMediaFormatterBase::prepareAttributes()
- FileMediaFormatterBase::viewElements in core/
modules/ file/ src/ Plugin/ Field/ FieldFormatter/ FileMediaFormatterBase.php - Builds a renderable array for a field value.
- FileVideoFormatter::prepareAttributes in core/
modules/ file/ src/ Plugin/ Field/ FieldFormatter/ FileVideoFormatter.php - Prepare the attributes according to the settings.
1 method overrides FileMediaFormatterBase::prepareAttributes()
- FileVideoFormatter::prepareAttributes in core/
modules/ file/ src/ Plugin/ Field/ FieldFormatter/ FileVideoFormatter.php - Prepare the attributes according to the settings.
File
- core/
modules/ file/ src/ Plugin/ Field/ FieldFormatter/ FileMediaFormatterBase.php, line 151
Class
- FileMediaFormatterBase
- Base class for media file formatter.
Namespace
Drupal\file\Plugin\Field\FieldFormatterCode
protected function prepareAttributes(array $additional_attributes = []) {
$attributes = new Attribute();
foreach (array_merge([
'controls',
'autoplay',
'loop',
], $additional_attributes) as $attribute) {
if ($this
->getSetting($attribute)) {
$attributes
->setAttribute($attribute, $attribute);
}
}
return $attributes;
}