示例#1
0
 /**
  * {@inheritdoc}
  */
 public function getForm(array &$original_form, FormStateInterface $form_state, array $aditional_widget_parameters)
 {
     /** @var \Drupal\media_entity\MediaBundleInterface $bundle */
     if (!$this->configuration['media bundle'] || !($bundle = $this->entityManager->getStorage('media_bundle')->load($this->configuration['media bundle']))) {
         return ['#markup' => t('The media bundle is not configured correctly.')];
     }
     if ($bundle->getType()->getPluginId() != 'image') {
         return ['#markup' => t('The configured bundle is not using image plugin.')];
     }
     $form = parent::getForm($original_form, $form_state, $aditional_widget_parameters);
     $form['upload']['upload_validators']['file_validate_extensions'] = [$this->configuration['extensions']];
     return $form;
 }