You are here

public function ImageZoomFieldFormatter::settingsForm in Image Field Zoom 8

Settings form.

Parameters

array $form: Form array.

\Drupal\Core\Form\FormStateInterface $form_state: Form state array.

Return value

mixed Returns mixed data.

Overrides FormatterBase::settingsForm

File

src/Plugin/Field/FieldFormatter/ImageZoomFieldFormatter.php, line 131
Contains Drupal\imagefield_zoom\Plugin\Field\FieldFormatter\ImageZoomFieldFormatter.

Class

ImageZoomFieldFormatter
Plugin implementation of the 'imagezoom_field_formatter' formatter.

Namespace

Drupal\imagefield_zoom\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $image_styles = image_style_options(FALSE);
  $description_link = Link::fromTextAndUrl($this
    ->t('Configure Image Styles'), Url::fromRoute('entity.image_style.collection'));
  $element['image_style'] = [
    '#title' => t('Image style'),
    '#type' => 'select',
    '#default_value' => $this
      ->getSetting('image_style'),
    '#empty_option' => t('None (original image)'),
    '#options' => $image_styles,
    '#description' => $description_link
      ->toRenderable() + [
      '#access' => $this->currentUser
        ->hasPermission('administer image styles'),
    ],
  ];
  $image_zoom_styles = array(
    'mouseover' => t('Mouse Over'),
    'grab' => t('Grab'),
    'click' => t('Click'),
    'toggle' => t('Toggle'),
  );
  $element['image_zoom_style'] = array(
    '#title' => t('Image Zoom Style'),
    '#type' => 'select',
    '#default_value' => $this
      ->getSetting('image_zoom_style'),
    '#options' => $image_zoom_styles,
  );
  $element['image_touchscreen_compatible'] = array(
    '#title' => t('Touchscreen Compatible'),
    '#type' => 'checkbox',
    '#default_value' => $this
      ->getSetting('image_touchscreen_compatible'),
  );
  $element['image_magnify'] = array(
    '#title' => t('Image Magnify'),
    '#type' => 'number',
    '#default_value' => $this
      ->getSetting('image_magnify'),
  );
  $element['image_fade_duration'] = array(
    '#title' => t('Fade Duration'),
    '#type' => 'number',
    '#default_value' => $this
      ->getSetting('image_fade_duration'),
  );
  return $element;
}