Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When uploading a file (image) through the media browser, I get the following javascript error (in Chrome, haven't tested others), which stops all other JS from executing:
Uncaught TypeError: Cannot read property 'length' of undefined
Steps to reproduce:
- Install Drupal (standard profile)
- Enable de media module (7.x-2.x-dev)
- Edit the article content type so that the image field uses the media browser
- Create an 'article' node
- Click 'Browse' on the image field and select an image from your local computer
- Check your console, the error should show up there
Comments
Comment #1
Jelle_SBoth the div around the file input as the file input itself have the "edit-upload-upload" HTML id, which can't be a good thing regardless of whether it's the cause or not (but I'm assuming it is). I can't seem to find where these ids are set or generated though...
Comment #2
predy CreditAttribution: predy commentedAfter digging up media and file entity module I ended up the issue is coming from core file.module. I'm opening a ticket and applying a patch, will provide a link afterwards.
Comment #3
predy CreditAttribution: predy at Penceo commentedThe patch mentioned above can be found here: https://www.drupal.org/node/2594955
Comment #4
bneil CreditAttribution: bneil at The University of Iowa commentedComment #5
chris.smith CreditAttribution: chris.smith at Portage CyberTech commentedConfirming that the patch #9 mentioned in #3 resolved the issue.
Comment #6
bneil CreditAttribution: bneil at The University of Iowa commentedComment #7
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedRecent versions of media have resolved most of peoples concerns and is compatible with entity translation, multilingual and various advanced configurations. Due to the high volume of inactive and most often irrelevant issues we are Closing this as (outdated). If for whatever reason this issue is important to you AND you still have issues after checking the media recipe documentation, then let us know and we will review your concerns.
Otherwise, see the recipe documentation for how to configure media and for troubleshooting tips OR refer to the media_dev distribution if you want to see a working media setup.
As mentioned, feel free to make some noise in this issue if you still feel it is important to you or someone else.
Thanks,
Media team
Comment #8
Rafal LukawieckiThis issue still shows up in 7.x-4.1. I can confirm that patch #9 for the core file module fixes it, see https://www.drupal.org/project/drupal/issues/2594955