/** * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { // Image selection. $options = ['#default_value' => isset($this->configuration['image_uri']) ? pathinfo($this->configuration['image_uri'], PATHINFO_BASENAME) : '']; $form['image_uri'] = $this->imageSelector->selectionElement($options); return $form; }
/** * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form['placement'] = ['#type' => 'radios', '#title' => $this->t('Placement'), '#options' => ['left-top' => $this->t('Top left'), 'center-top' => $this->t('Top center'), 'right-top' => $this->t('Top right'), 'left-center' => $this->t('Center left'), 'center-center' => $this->t('Center'), 'right-center' => $this->t('Center right'), 'left-bottom' => $this->t('Bottom left'), 'center-bottom' => $this->t('Bottom center'), 'right-bottom' => $this->t('Bottom right')], '#theme' => 'image_anchor', '#default_value' => $this->configuration['placement'], '#description' => $this->t('Position of the watermark on the underlying image.')]; $form['x_offset'] = ['#type' => 'number', '#title' => $this->t('Horizontal offset'), '#field_suffix' => 'px', '#description' => $this->t('Additional horizontal offset from placement.'), '#default_value' => $this->configuration['x_offset'], '#maxlength' => 4, '#size' => 4]; $form['y_offset'] = ['#type' => 'number', '#title' => $this->t('Vertical offset'), '#field_suffix' => 'px', '#description' => $this->t('Additional vertical offset from placement.'), '#default_value' => $this->configuration['y_offset'], '#maxlength' => 4, '#size' => 4]; $form['opacity'] = ['#type' => 'number', '#title' => $this->t('Opacity'), '#field_suffix' => '%', '#description' => $this->t('Opacity: 0 - 100'), '#default_value' => $this->configuration['opacity'], '#min' => 0, '#max' => 100, '#maxlength' => 3, '#size' => 3]; $options = ['#title' => $this->t('File name'), '#description' => $this->t('Image to use for watermark effect.'), '#default_value' => $this->configuration['watermark_image']]; $form['watermark_image'] = $this->imageSelector->selectionElement($options); return $form; }