You are here

public function WebformImageFile::form in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/WebformImageFile.php \Drupal\webform\Plugin\WebformElement\WebformImageFile::form()

Gets the actual configuration webform array to be built.

Parameters

array $form: An associative array containing the structure of the form.

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

Return value

array An associative array contain the element's configuration webform without any default values.

Overrides WebformManagedFileBase::form

File

src/Plugin/WebformElement/WebformImageFile.php, line 120

Class

WebformImageFile
Provides a 'webform_image_file' element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
  $form['image'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Image settings'),
  ];
  $form['image']['max_resolution'] = [
    '#type' => 'webform_image_resolution',
    '#title' => $this
      ->t('Maximum image resolution'),
    '#description' => $this
      ->t('The maximum allowed image size expressed as WIDTH×HEIGHT (e.g. 640×480). Leave blank for no restriction. If a larger image is uploaded, it will be resized to reflect the given width and height. Resizing images on upload will cause the loss of <a href="http://wikipedia.org/wiki/Exchangeable_image_file_format">EXIF data</a> in the image.'),
    '#width_title' => $this
      ->t('Maximum width'),
    '#height_title' => $this
      ->t('Maximum height'),
  ];
  $form['image']['min_resolution'] = [
    '#type' => 'webform_image_resolution',
    '#title' => $this
      ->t('Minimum image resolution'),
    '#description' => $this
      ->t('The minimum allowed image size expressed as WIDTH×HEIGHT (e.g. 640×480). Leave blank for no restriction. If a smaller image is uploaded, it will be rejected.'),
    '#width_title' => $this
      ->t('Minimum width'),
    '#height_title' => $this
      ->t('Minimum height'),
  ];
  if ($this->moduleHandler
    ->moduleExists('image')) {
    $form['image']['attachment_image_style'] = [
      '#type' => 'select',
      '#options' => image_style_options(),
      '#title' => $this
        ->t('Attachment image style'),
      '#description' => $this
        ->t('Use this to send image with image style when sending files as attachment in an email handler.'),
    ];
  }
  return $form;
}