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:

  1. Install Drupal (standard profile)
  2. Enable de media module (7.x-2.x-dev)
  3. Edit the article content type so that the image field uses the media browser
  4. Create an 'article' node
  5. Click 'Browse' on the image field and select an image from your local computer
  6. Check your console, the error should show up there

Comments

Jelle_S’s picture

<div class="form-item form-type-managed-file form-item-upload">
  <label for="edit-upload-upload">Upload a new file <span class="form-required" title="This field is required.">*</span></label>
 <div id="edit-upload-upload" class="form-managed-file"><input type="file" id="edit-upload-upload" name="files[upload]" size="22" class="form-file"><input type="submit" id="edit-upload-upload-button" name="upload_upload_button" value="Upload" class="form-submit ajax-processed"><input type="hidden" name="upload[fid]" value="0">
</div>
<div class="description">Files must be less than <strong>2 MB</strong>.<br>Allowed file types: <strong>png gif jpg jpeg</strong>.</div>
</div>

Both 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...

predy’s picture

After 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.

predy’s picture

The patch mentioned above can be found here: https://www.drupal.org/node/2594955

bneil’s picture

chris.smith’s picture

Confirming that the patch #9 mentioned in #3 resolved the issue.

bneil’s picture

Chris Matthews’s picture

Status: Active » Closed (outdated)

Recent 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

Rafal Lukawiecki’s picture

This 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