function FileVideoFormatter::settingsForm
Same name and namespace in other branches
- 10 core/modules/file/src/Plugin/Field/FieldFormatter/FileVideoFormatter.php \Drupal\file\Plugin\Field\FieldFormatter\FileVideoFormatter::settingsForm()
- 11.x core/modules/file/src/Plugin/Field/FieldFormatter/FileVideoFormatter.php \Drupal\file\Plugin\Field\FieldFormatter\FileVideoFormatter::settingsForm()
- 9 core/modules/file/src/Plugin/Field/FieldFormatter/FileVideoFormatter.php \Drupal\file\Plugin\Field\FieldFormatter\FileVideoFormatter::settingsForm()
- 8.9.x core/modules/file/src/Plugin/Field/FieldFormatter/FileVideoFormatter.php \Drupal\file\Plugin\Field\FieldFormatter\FileVideoFormatter::settingsForm()
Overrides FileMediaFormatterBase::settingsForm
File
-
core/
modules/ file/ src/ Plugin/ Field/ FieldFormatter/ FileVideoFormatter.php, line 92
Class
- FileVideoFormatter
- Plugin implementation of the 'file_video' formatter.
Namespace
Drupal\file\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$fields = $this->entityFieldManager
->getFieldDefinitions($form['#entity_type'], $form['#bundle']);
// Get all image fields for html5 poster.
$image_fields = [];
foreach ($fields as $field) {
if ($field->getType() == 'image') {
$image_fields[$field->getName()] = $field->getLabel();
}
}
$image_styles = \Drupal::service(ImageDerivativeUtilities::class)->styleOptions();
$image_styles_description_link = Link::fromTextAndUrl($this->t('Configure Image Styles'), Url::fromRoute('entity.image_style.collection'));
return parent::settingsForm($form, $form_state) + [
'muted' => [
'#title' => $this->t('Muted'),
'#type' => 'checkbox',
'#default_value' => $this->getSetting('muted'),
],
'playsinline' => [
'#title' => $this->t('Plays Inline'),
'#type' => 'checkbox',
'#default_value' => $this->getSetting('playsinline'),
],
'width' => [
'#type' => 'number',
'#title' => $this->t('Width'),
'#default_value' => $this->getSetting('width'),
'#size' => 5,
'#maxlength' => 5,
'#field_suffix' => $this->t('pixels'),
// A width of zero pixels would make this video invisible.
'#min' => 1,
],
'height' => [
'#type' => 'number',
'#title' => $this->t('Height'),
'#default_value' => $this->getSetting('height'),
'#size' => 5,
'#maxlength' => 5,
'#field_suffix' => $this->t('pixels'),
// A height of zero pixels would make this video invisible.
'#min' => 1,
],
'poster' => [
'#type' => 'select',
'#title' => $this->t('Poster field'),
'#description' => $this->t('An image field to use as the source of the poster attribute'),
'#default_value' => $this->getSetting('poster'),
'#options' => $image_fields,
'#empty_option' => $this->t('- None -'),
],
'poster_image_style' => [
'#type' => 'select',
'#title' => $this->t('Poster field image style'),
'#default_value' => $this->getSetting('poster_image_style'),
'#options' => $image_styles,
'#empty_option' => $this->t('None (original image)'),
'#description' => $image_styles_description_link->toRenderable() + [
'#access' => $this->currentUser
->hasPermission('administer image styles'),
],
'#states' => [
'visible' => [
':input[name$="[settings][poster]"]' => [
'filled' => TRUE,
],
],
],
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.