You are here

public function PhotosImageCover::buildOptionsForm in Album Photos 6.0.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/views/field/PhotosImageCover.php \Drupal\photos\Plugin\views\field\PhotosImageCover::buildOptionsForm()

Provide the options form.

Overrides FieldPluginBase::buildOptionsForm

File

src/Plugin/views/field/PhotosImageCover.php, line 103

Class

PhotosImageCover
Field handler to display album cover in views.

Namespace

Drupal\photos\Plugin\views\field

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {

  // Link options.
  $form['link_photo'] = [
    '#title' => $this
      ->t("Link image"),
    '#description' => $this
      ->t("Link the image to the album page or image page."),
    '#type' => 'radios',
    '#options' => [
      '' => $this
        ->t('None'),
      'album' => $this
        ->t('Album page'),
      'image' => $this
        ->t('Image page'),
    ],
    '#default_value' => $this->options['link_photo'],
  ];

  // Get image styles.
  $viewModeOptions = $this->entityDisplayRepository
    ->getViewModeOptionsByBundle('photos_image', 'photos_image');
  $default = '';
  if (isset($viewModeOptions['cover'])) {
    $default = 'cover';
  }
  $form['view_mode'] = [
    '#title' => $this
      ->t('View mode'),
    '#type' => 'select',
    '#default_value' => $this->options['view_mode'] ?: $default,
    '#options' => $viewModeOptions,
  ];
  parent::buildOptionsForm($form, $form_state);
}