You are here

public function MediaElementFieldFormatterTrait::settingsForm in MediaElement 8

1 call to MediaElementFieldFormatterTrait::settingsForm()
MediaElementVideoFieldFormatter::settingsForm in src/Plugin/Field/FieldFormatter/MediaElementVideoFieldFormatter.php
Returns a form to configure settings for the formatter.

File

src/Plugin/Field/FieldFormatter/MediaElementFieldFormatterTrait.php, line 27

Class

MediaElementFieldFormatterTrait
Common methods for MediaElement.js processing.

Namespace

Drupal\mediaelement\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  return parent::settingsForm($form, $form_state) + [
    'preload' => [
      '#type' => 'select',
      '#title' => $this
        ->t('Preload'),
      '#description' => $this
        ->t('The preload attribute specifies if and how the author thinks that the video should be loaded when the page loads.'),
      '#default_value' => $this
        ->getSetting('preload'),
      '#options' => [
        'auto' => 'auto',
        'metadata' => 'metadata',
        'none' => 'none',
      ],
    ],
    'download_link' => [
      '#title' => $this
        ->t('Download Link'),
      '#type' => 'checkbox',
      '#default_value' => $this
        ->getSetting('download_link'),
    ],
    'download_text' => [
      '#title' => $this
        ->t('Download Text'),
      '#type' => 'textfield',
      '#default_value' => $this
        ->getSetting('download_text'),
      '#states' => [
        'visible' => [
          ':input[name*="download_link"]' => [
            'checked' => TRUE,
          ],
        ],
      ],
    ],
  ];
}