How do I remove dropzone from entity browser modals?

Created on 5 February 2024, 10 months ago

Problem/Motivation

I installed Dropzone as part of Simple Media Bulk Upload, so that users could bulk upload many images at one time via a specific screen in the CMS.

However, it's causing issues for whatever reason on the individual entity browsers when adding an image to our Paragraph components.

(The issue is that when an image is added, it briefly shows the thumbnail, then clears everything and only shows the Dropzone widget, and never accepts another image until I close the modal completely.)

Is there a way to disable the dropzone widget on the entity browser itself?

I've tried via /admin/config/content/entity_browser and my current widgets aren't even mentioning Dropzone at all, but I can't remove it, even if I delete all the widgets completely.

Where is this being added?

✨ Feature request
Status

Active

Version

2.8

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States nessthehero

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @nessthehero
  • πŸ‡¦πŸ‡ΊAustralia almunnings Melbourne, πŸ‡¦πŸ‡Ί

    Create a custom module. Eg:

    In a mymodule.module file

    
    use Drupal\media_library\Form\FileUploadForm;
    
    /**
     * Implements hook_media_source_info_alter().
     *
     * - Disable dropzonejs for media library add form.
     */
    function MYMODULE_media_source_info_alter(array &$sources) {
      if (!\Drupal::moduleHandler()->moduleExists('dropzonejs')) {
        return;
      }
    
      if (isset($sources['image'])) {
        $sources['image']['forms']['media_library_add'] = FileUploadForm::class;
      }
    
      if (isset($sources['video_file'])) {
        $sources['video_file']['forms']['media_library_add'] = FileUploadForm::class;
      }
    
      if (isset($sources['audio_file'])) {
        $sources['audio_file']['forms']['media_library_add'] = FileUploadForm::class;
      }
    
      if (isset($sources['file'])) {
        $sources['file']['forms']['media_library_add'] = FileUploadForm::class;
      }
    }
    
    

    And in a mymodule.install file

    
    /**
     * Implements hook_install().
     */
    function MYMODULE_install() {
      module_set_weight('mymodule', 50);
    }
    
    

    This should disable it on the normal forms. Weight 50 is just a random number I chose, it just needs to run after dropzonejs module.

Production build 0.71.5 2024