You are here

public function FilterUrlToVideo::settingsForm in URL to Video Filter 2.0.x

Same name and namespace in other branches
  1. 8 src/Plugin/Filter/FilterUrlToVideo.php \Drupal\url_to_video_filter\Plugin\Filter\FilterUrlToVideo::settingsForm()

Generates a filter's settings form.

Parameters

array $form: A minimally prepopulated form array.

\Drupal\Core\Form\FormStateInterface $form_state: The state of the (entire) configuration form.

Return value

array The $form array with additional form elements for the settings of this filter. The submitted form values should match $this->settings.

Overrides FilterBase::settingsForm

File

src/Plugin/Filter/FilterUrlToVideo.php, line 119

Class

FilterUrlToVideo
Provides a filter to convert various video sharing website URLs to links.

Namespace

Drupal\url_to_video_filter\Plugin\Filter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {

  // Enable filtering for YouTube URLs.
  $form['youtube'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Filter for YouTube URLs'),
    '#default_value' => $this->settings['youtube'],
  ];
  $form['youtube_webp_preview'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Use webp image for YouTube preview'),
    '#description' => $this
      ->t('Warning - not compatible with some browsers'),
    '#default_value' => $this->settings['youtube_webp_preview'],
    '#states' => [
      'visible' => [
        '#edit-filters-filter-url-to-video-settings-youtube' => [
          'checked' => TRUE,
        ],
        '#edit-filters-filter-url-to-video-settings-autoload' => [
          'checked' => FALSE,
        ],
      ],
    ],
  ];

  // Enable filtering for Vimeo URLs.
  $form['vimeo'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Filter for Vimeo URLs'),
    '#default_value' => $this->settings['vimeo'],
  ];
  $form['autoload'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Autoload players when page has loaded.'),
    '#default_value' => $this->settings['autoload'],
  ];
  return $form;
}