Skip to content

Commit

Permalink
Add Image fields only to Image derivative code.
Browse files Browse the repository at this point in the history
Co-authored-by: @ajstanley <alanjarlathstanley@gmail.com>
  • Loading branch information
rosiel and ajstanley committed Jul 26, 2022
1 parent 42e703c commit 3b4dea9
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,23 @@ public function defaultConfiguration() {
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
$form['mimetype']['#description'] = $this->t('Mimetype to convert to (e.g. application/xml, etc...)');
$map = $this->entityFieldManager->getFieldMapByFieldType('image');
$file_fields = $map['media'];
$file_options = array_combine(array_keys($file_fields), array_keys($file_fields));
$file_options = array_merge(['' => ''], $file_options);
// @todo figure out how to write to thumbnail, which is not a real field.
// see https://github.com/Islandora/islandora/issues/891.
unset($file_options['thumbnail']);

$form['destination_field_name'] = [
'#required' => TRUE,
'#type' => 'select',
'#options' => $file_options,
'#title' => $this->t('Destination Image field Name'),
'#default_value' => $this->configuration['destination_field_name'],
'#description' => $this->t('Image field on Media to hold derivative. Cannot be the same as source'),
];

$form['mimetype']['#value'] = 'image/jpeg';
$form['mimetype']['#type'] = 'hidden';
return $form;
Expand Down

0 comments on commit 3b4dea9

Please sign in to comment.