You are here

public function ImageZoomFormatter::settingsForm in Image Zoom 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/Field/FieldFormatter/ImageZoomFormatter.php \Drupal\imagezoom\Plugin\Field\FieldFormatter\ImageZoomFormatter::settingsForm()

Returns a form to configure settings for the formatter.

Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the formatter. The field_ui module takes care of handling submitted form values.

Parameters

array $form: The form where the settings form is being included in.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form elements for the formatter settings.

Overrides FormatterBase::settingsForm

1 call to ImageZoomFormatter::settingsForm()
ImageZoomGalleryFormatter::settingsForm in modules/imagezoom_gallery/src/Plugin/Field/FieldFormatter/ImageZoomGalleryFormatter.php
Returns a form to configure settings for the formatter.
1 method overrides ImageZoomFormatter::settingsForm()
ImageZoomGalleryFormatter::settingsForm in modules/imagezoom_gallery/src/Plugin/Field/FieldFormatter/ImageZoomGalleryFormatter.php
Returns a form to configure settings for the formatter.

File

src/Plugin/Field/FieldFormatter/ImageZoomFormatter.php, line 93

Class

ImageZoomFormatter
Image Zoom field formatter for Image fields.

Namespace

Drupal\imagezoom\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $element['imagezoom_zoom_type'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Zoom type'),
    '#options' => $this
      ->zoomTypes(),
    '#default_value' => $this
      ->getSetting('imagezoom_zoom_type'),
  ];
  $image_styles = image_style_options(FALSE);
  $element['imagezoom_display_style'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Image style'),
    '#options' => $image_styles,
    '#empty_option' => $this
      ->t('None (original image)'),
    '#default_value' => $this
      ->getSetting('imagezoom_display_style'),
  ];
  $element['imagezoom_zoom_style'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Zoomed Image style'),
    '#options' => $image_styles,
    '#empty_option' => $this
      ->t('None (original image)'),
    '#default_value' => $this
      ->getSetting('imagezoom_zoom_style'),
  ];
  $element['imagezoom_disable'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Disable zoom on small screens'),
    '#return_value' => 1,
    '#default_value' => $this
      ->getSetting('imagezoom_disable'),
    '#weight' => 10,
  ];
  $element['imagezoom_disable_width'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Minimum width for zoom to display'),
    '#min' => 0,
    '#states' => [
      'invisible' => [
        ':input[name="fields[field_image][settings_edit_form][settings][imagezoom_disable]"]' => [
          'checked' => FALSE,
        ],
      ],
    ],
    '#default_value' => $this
      ->getSetting('imagezoom_disable_width'),
    '#weight' => 10,
  ];
  $docs = Link::fromTextAndUrl($this
    ->t('documentation'), Url::fromUri('http://igorlino.github.io/elevatezoom-plus/api.htm'));
  $element['imagezoom_additional'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Additional settings'),
    '#element_validate' => [
      [
        $this,
        'additionalSettingsValidate',
      ],
    ],
    '#description' => $this
      ->t('Add additional settings. For a list of available options, see the @docs. Settings should be added in the following format: <pre>@code</pre>', [
      '@docs' => $docs
        ->toString(),
      '@code' => 'option: value',
    ]),
    '#default_value' => $this
      ->getSetting('imagezoom_additional'),
    '#weight' => 20,
  ];
  return $element;
}