The original hook of the upload area of a media library is HOOK_form_media_library_add_form_upload_alter
.
This hook is widely used on contrib and core areas to provide extra funcionality for the upload form, such as field_groups in order to support Media Library:
/**
* Implements hook_form_media_library_add_form_upload_alter().
*/
function field_group_form_media_library_add_form_upload_alter(&$form, FormStateInterface $form_state) {
// Attach the fieldgroups to the media entity form in Media Library widget.
$storage = $form_state->getStorage();
if (!empty($storage['media'])) {
foreach ($storage['media'] as $delta => $media) {
(...)
}
}
}
or the core theme Claro:
/**
* Implements hook_form_FORM_ID_alter().
*/
function claro_form_media_library_add_form_upload_alter(array &$form, FormStateInterface $form_state) {
$form['#attributes']['class'][] = 'media-library-add-form--upload';
if (isset($form['container']['upload'])) {
( ... )
}
}
.
All of this functionality, which affect the whole form (and not only the upload file field), disappears when using dropzonejs as the hook changes from HOOK_form_media_library_add_form_upload_alter
to HOOK_form_media_library_add_form_dropzonejs_alter
.
The only workaround is to manually forward the new hook to the old one:
/**
* Implements hook_form_FORM_ID_alter().
*
* The dropzonejs module modifies the form hook alter of the media library upload
* area, preventing modules such as field_group from performing its operations.
* We need to manually add the hooks to preserve the field group functionality.
*/
function uw_media_form_media_library_add_form_dropzonejs_alter(&$form, FormStateInterface $form_state) {
field_group_form_media_library_add_form_upload_alter($form, $form_state);
}
I think this module should take care of ensuring that the additions made to the original file upload form on media library are not lost when using dropzonejs.