|
|
@ -6,7 +6,10 @@ use Drupal\Core\Form\FormStateInterface; |
|
|
|
use Drupal\islandora\Plugin\Action\AbstractGenerateDerivativeMediaFile; |
|
|
|
use Drupal\islandora\Plugin\Action\AbstractGenerateDerivativeMediaFile; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Emits a Node for generating derivatives event. |
|
|
|
* Emits a Media for generating derivatives event. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* Attaches the result as a file in an image field on the emitting |
|
|
|
|
|
|
|
* Media ("multi-file media"). |
|
|
|
* |
|
|
|
* |
|
|
|
* @Action( |
|
|
|
* @Action( |
|
|
|
* id = "generate_image_derivative_file", |
|
|
|
* id = "generate_image_derivative_file", |
|
|
@ -24,7 +27,6 @@ class GenerateImageDerivativeFile extends AbstractGenerateDerivativeMediaFile { |
|
|
|
$config['path'] = '[date:custom:Y]-[date:custom:m]/[media:mid]-ImageService.jpg'; |
|
|
|
$config['path'] = '[date:custom:Y]-[date:custom:m]/[media:mid]-ImageService.jpg'; |
|
|
|
$config['mimetype'] = 'application/xml'; |
|
|
|
$config['mimetype'] = 'application/xml'; |
|
|
|
$config['queue'] = 'islandora-connector-houdini'; |
|
|
|
$config['queue'] = 'islandora-connector-houdini'; |
|
|
|
$config['destination_media_type'] = 'file'; |
|
|
|
|
|
|
|
$config['scheme'] = $this->config->get('default_scheme'); |
|
|
|
$config['scheme'] = $this->config->get('default_scheme'); |
|
|
|
return $config; |
|
|
|
return $config; |
|
|
|
} |
|
|
|
} |
|
|
@ -34,9 +36,30 @@ class GenerateImageDerivativeFile extends AbstractGenerateDerivativeMediaFile { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function buildConfigurationForm(array $form, FormStateInterface $form_state) { |
|
|
|
public function buildConfigurationForm(array $form, FormStateInterface $form_state) { |
|
|
|
$form = parent::buildConfigurationForm($form, $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'), |
|
|
|
|
|
|
|
'#default_value' => $this->configuration['destination_field_name'], |
|
|
|
|
|
|
|
'#description' => $this->t('This Action stores the derivative in an |
|
|
|
|
|
|
|
Image field. If you need to store the result in a File field, use |
|
|
|
|
|
|
|
"Generate a Derivative File for Media Attachment". Selected target field |
|
|
|
|
|
|
|
must be an additional field, not the media\'s main storage field. |
|
|
|
|
|
|
|
Selected target field must be present on the media.'), |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
$form['mimetype']['#value'] = 'image/jpeg'; |
|
|
|
$form['mimetype']['#value'] = 'image/jpeg'; |
|
|
|
$form['mimetype']['#type'] = 'hidden'; |
|
|
|
$form['mimetype']['#description'] = 'Mimetype to convert to. Must be |
|
|
|
|
|
|
|
compatible with the destination image field.'; |
|
|
|
return $form; |
|
|
|
return $form; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|