I'm seeing the error "Drupal.settings.media_format_form is undefined" in my JS console when using the WYSIWYG to add media to a text area. This happens when I move from choosing the file to choosing the format.

The issue seems to be that:

    if (Drupal.settings.media_format_form.autosubmit) {
      $('.button.fake-ok').click();
    }

was left over from the switch to views (or what ever happened). If this code is commented out or removed the error goes away but everything works. At no time in the current code is Drupal.settings.media_format_form every created as an object.

Note, this code is in media.format_form.js

Comments

jarrodirwin’s picture

Component: Code » WYSIWYG integration
StatusFileSize
new622 bytes

I have created a patch that removes this code as I am having a similar issues with it.

When adding video files, the second popup auto-submits and does not allow the user to select a formatter. This is due to the Drupal.settings.media_format_form object being empty and Drupal.settings.media_format_form.autosubmit returning TRUE.

When adding images however, the object is not empty and has autosubmit set to FALSE so it does not auto-submit.

I feel there is a bigger issue here but this is currently needed until that is sorted.

dddave’s picture

Status: Active » Needs review

Correcting status.

idflood’s picture

I wasn't able to reproduce the issue, probably a mistake on my part. But the patch looks good, and the only reference to an "autosubmit" option is related to the view's exposed form.

$handler->display->display_options['exposed_form']['options']['autosubmit'] = 1;

I would mark this rtbc without hesitation if I would be able to reproduce the error.

drzraf’s picture

hit this one too, after applying the patch the process goes a bit further but stop again with:

imgElement is undefined
for (i=0; i< imgElement.attributes.length; i++) {
/sites/all/modules/media/js/wysiwyg-media.js?lu05nb  (ligne 195)

definitively something wrong.
hints to debug this ?

drzraf’s picture

a very similar behaviour is described in #1062948: Issue getting Media, Styles and WYSIWYG working together with MediaElement.js
forgot to say that I was trying to insert a PDF file with the media wysiwyg icon and the View library while the "standard" library was not offering this file type (image/audio only).

drzraf’s picture

still happen, can reproduce with any formatter which output something else than <img>.
Related: #1261194: Inline Player insertion and WYSIWYG Editor Integration and #1283844: [meta] Improve WYSIWYG integration

[edit] patch #4 of the later, did the trick

andrewbelcher’s picture

Not sure if this helps anyone else, but I ran into the autosubmit issue. Turns out it's not down to the view. In my case, both media_vimeo and media_youtube were setting the autosubmit, thus breaking that page. Possibly media shouldn't allow the ability to autosubmit as it allows other modules to break core functionality, but if you've got the same issue I've created issues in media_vimeo #1424120: Setting autosubmit breaks core media functionality and media_youtube #1240976: Allow users embedding videos with the insert Media wysiwyg button to pick display format which have patches attached...

devin carlson’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #1 still applies cleanly and removes the ability to automatically submit the form.

To my knowledge this was only ever used as a hack by media players such as YouTube and Vimeo to get around limitations of Media which have since been fixed.

aaron’s picture

Status: Reviewed & tested by the community » Needs work

The last submitted patch, remove-legacy-form-autosubmit_1301774_1.patch, failed testing.

ParisLiakos’s picture

Status: Needs work » Needs review
StatusFileSize
new672 bytes

reroll

ParisLiakos’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

cyberwolf’s picture

StatusFileSize
new700 bytes

Also encountering some problems within media 7.x-1.x with the autosubmit code causing JavaScript errors. Attached is a patch for Media 7.x-1.3 which removes it there, using a similar approach as in #11.

dddave’s picture

Version: 7.x-2.x-dev » 7.x-1.3
Status: Closed (fixed) » Needs work

Haven't tested it as I don't use the 1.x branch but patches should be against dev.

devin carlson’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
Assigned: Unassigned » devin carlson
Status: Needs work » Needs review
Issue tags: +needs backport to 1.x
StatusFileSize
new700 bytes

I suppose that this could be backported. Anyone that still desires this functionality should be able to alter it back in.

devin carlson’s picture

Status: Needs review » Fixed

Committed to Media 7.x-1.x.

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

added a pointer to the js file