function FileVideoFormatter::prepareAttributes

Same name in other branches
  1. 9 core/modules/file/src/Plugin/Field/FieldFormatter/FileVideoFormatter.php \Drupal\file\Plugin\Field\FieldFormatter\FileVideoFormatter::prepareAttributes()
  2. 8.9.x core/modules/file/src/Plugin/Field/FieldFormatter/FileVideoFormatter.php \Drupal\file\Plugin\Field\FieldFormatter\FileVideoFormatter::prepareAttributes()
  3. 10 core/modules/file/src/Plugin/Field/FieldFormatter/FileVideoFormatter.php \Drupal\file\Plugin\Field\FieldFormatter\FileVideoFormatter::prepareAttributes()

Overrides FileMediaFormatterBase::prepareAttributes

File

core/modules/file/src/Plugin/Field/FieldFormatter/FileVideoFormatter.php, line 98

Class

FileVideoFormatter
Plugin implementation of the 'file_video' formatter.

Namespace

Drupal\file\Plugin\Field\FieldFormatter

Code

protected function prepareAttributes(array $additional_attributes = []) {
    $attributes = parent::prepareAttributes([
        'muted',
    ]);
    if ($width = $this->getSetting('width')) {
        $attributes->setAttribute('width', $width);
    }
    if ($height = $this->getSetting('height')) {
        $attributes->setAttribute('height', $height);
    }
    return $attributes;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.