/**
  * {@inheritdoc}
  */
 public function fieldSettingsForm(array $form, FormStateInterface $form_state)
 {
     $element = array();
     $field_settings = $this->getSettings();
     $embridge_settings = \Drupal::config('embridge.settings');
     /** @var EmbridgeCatalog[] $entities */
     $entities = EmbridgeCatalog::loadMultiple();
     $options = [];
     foreach ($entities as $entity) {
         $options[$entity->id()] = $entity->label();
     }
     $element['catalog_id'] = array('#type' => 'select', '#title' => t('Catalog'), '#default_value' => $field_settings['catalog_id'], '#options' => $options, '#description' => t("Select the Catalog to source media from for this field."), '#required' => TRUE, '#weight' => 6);
     $libraries_admin = Link::fromTextAndUrl('libraries admin', Url::fromUri($embridge_settings->get('uri') . '/' . $field_settings['catalog_id'] . '/views/modules/library/index.html'));
     $element['library_id'] = array('#type' => 'textfield', '#title' => t('Library'), '#default_value' => $field_settings['library_id'], '#description' => t("Limit uploads via this field to a specific library. This will also provide a default library on the asset search advanced filter. To identify the library ID, select the library on the @libraries_admin page and note the ID.", ['@libraries_admin' => $libraries_admin->toString()]), '#required' => FALSE, '#size' => 10, '#weight' => 6);
     $element['allow_search'] = array('#type' => 'checkbox', '#title' => t('Allow search'), '#default_value' => $field_settings['allow_search'], '#description' => t("Check this to allow users to search EMDB for existing assets, requires <em>search embridge assets</em> permission."), '#weight' => 6);
     return $element + parent::fieldSettingsForm($form, $form_state);
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 public function preSave()
 {
     parent::preSave();
     $width = $this->width;
     $height = $this->height;
     // Determine the dimensions if necessary.
     if (empty($width) || empty($height)) {
         $image = \Drupal::service('image.factory')->get($this->entity->getFileUri());
         if ($image->isValid()) {
             $this->width = $image->getWidth();
             $this->height = $image->getHeight();
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function preSave()
 {
     parent::preSave();
 }