I have a form with a wysiwyg media integration and a multi field file with the media widget.
When I upload more than 2 files in my field file, I can't upload an image in the wysiwyg. The popup freeze with the message : "The file image_2MB.jpg was uploaded".

I use CKeditor with the wysiwyg module.

Do you know what is the problem ?

Files: 
CommentFileSizeAuthor
#25 media-js-error-on-wysiwyg-with-multi-field-1630288-25-do-not-test.patch1.04 KBdagomar
#22 media-js-error-on-wysiwyg-with-multi-field-1630288-22-do-not-test.patch1020 bytesndobromirov
#21 media-js-error-on-wysiwyg-with-multi-field-1630288-21.patch1.04 KBndobromirov
PASSED: [[SimpleTest]]: [MySQL] 914 pass(es).
[ View ]
#19 media-js-error-on-wysiwyg-with-multi-field-1630288-19.patch1.38 KBGoZ
PASSED: [[SimpleTest]]: [MySQL] 92 pass(es).
[ View ]
#16 media-1630288-16.patch1.01 KBJohn Pitcairn
PASSED: [[SimpleTest]]: [MySQL] 92 pass(es).
[ View ]
#4 media-1630288-4.patch1.03 KBcedric
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]
#1 media-1630288-1.patch1.05 KBcedric
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch media-1630288-1.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Comments

Version:7.x-1.1» 7.x-1.2
StatusFileSize
new1.05 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch media-1630288-1.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

The bug is also present on 7.x-1.2

The javascript error was:

Uncaught TypeError: Object /media/-media_id-/format-form?render=media-popup,/media/-media_id-/format-form?render=media-popup,/media/-media_id-/format-form?render=media-popup,/media/-media_id-/format-form?render=media-popup has no method 'replace'

Attached patch handles the cases where defaults.src is an array of strings and seems to fix the issue. Can someone with more knowledge of the code review this?

Status:Active» Needs review

Status:Needs review» Needs work

The last submitted patch, media-1630288-1.patch, failed testing.

StatusFileSize
new1.03 KB
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]

proper patch

Status:Needs work» Needs review

Status:Needs review» Reviewed & tested by the community

Amazing! Patch in #4 made my day. Tested and approved.

I noticed that this code also still exists in V 7.X-2.x. Could someone please let us know if the bugs still exists in that version? If so, then we will need to fix it there first, and then back port.

Version:7.x-1.2» 7.x-2.x-dev
Status:Reviewed & tested by the community» Needs work

+++ b/js/media.popups.jsundefined
@@ -150,8 +150,18 @@ Drupal.media.popups.mediaBrowser.finalizeSelection = function () {
+    defaults.src = defaults.src.replace('-media_id-', mediaFile.fid);  ¶
...
+  ¶
...
+  ¶

patch also contains 3 white spaces

Similar issue in 7.x-2-x yes. I came across it when using media with Panels (see #1901516: Inserting media in WYSIWYG textarea while using Panels, which is marked as duplicate of this):

* Add a custom panel pane to a panel page.
* Click the 'Add media' button in the WYSIWYG editor.
* Upload a file or find one in the library.
* Click submit.

Clicking submit should take you the file edit form (when uploading a new file) or the file style form (when choosing one from the library) in the modal, but it doesn't in this case.

After applying the patch in #4, when uploading a new file, the file edit form is loaded, but when I click 'Save', I'm getting the message that 'File <file_name> was updated, in an otherwise empty modal, and the modal is frozen, with no way to close it.

After applying the patch in #4, when choosing a file from the library and clicking 'Submit', nothing happens.

In both cases, the console shows:

Uncaught TypeError: Object /media/-media_id-/format-form?render=media-popup,/media/-media_id-/format-form?render=media-popup has no method 'replace' (program):155
Drupal.media.popups.mediaStyleSelector (program):155
InsertMedia.onSelect (program):163
s jquery.js:36
dialogOptions.buttons.(anonymous function) (program):84
Drupal.media.popups.mediaBrowser.mediaBrowserOnLoad (program):108
c.event.handle jquery.js:64
h.handle.o jquery.js:57

@brunodbo - I couldn't seem to reproduce the error. Without any patching everything seemed to work when I tried it. Can this be reproduced on a fresh install?

Just tested it on a fresh install of everything, and indeed, all seems good. #11 is invalid, sorry for the noise.

I've experienced the same issue on the latest media module in a panopoly installation.
The patch from #4 helped to fix the problem.

I am experiencing this issue in 7.x-2.0-unstable7 or 7.x-2.0-dev.

I have media-image fields contained in a multivalue field collection, and media-wysiwyg integration on the node body field. The Wysiwyg popup uses a cloned and customized Views display. If I add more than one field collection item containing an image, wysiwyg image selection from the popup fails with the javascript error:

media.popups.js:152 - TypeError: 'undefined' is not a function (evaluating 'defaults.src.replace('-media_id-', mediaFile.fid)')

The patch at #4 applies (with whitespace errors) to latest dev or 7.x-2.0-unstable7 and prevents the error.

But I am finding that the first item inserted from the popup is "sticky", ie if you go back and attempt to insert another item elsewhere in the text, you can select a different item and submit at step 1, but at the next step (choose format), the first-inserted item is displayed, and submitting inserts that.

The last item in the defaults.src array still contains the fid from the previous insert, so the replace on "-media_id-" does not find anything to replace.

StatusFileSize
new1.01 KB
PASSED: [[SimpleTest]]: [MySQL] 92 pass(es).
[ View ]

This updated patch adds a regex search for either possibility and removes the whitespace errors. I thought it prudent to check for the slashes either side of the relevant path argument rather than just a run of numbers (fid).

Status:Needs work» Needs review

Status:Needs review» Needs work

The last patch #16 doesn't work for me.
I am getting a 404 with this URL "/media/-media_id-/format-form?render=media-popup,/media/297/format-form?render=media-popup"
Maybe this is the Array case, but I am only inserting one image, so I don't know why this happens.

I am using ckeditor module (not wysiwyg) and fieldable_panel_panes module.
On first look, patch #4 works for me, and I am redirected to "/media/298/format-form?render=media-popup"

Status:Needs work» Needs review
StatusFileSize
new1.38 KB
PASSED: [[SimpleTest]]: [MySQL] 92 pass(es).
[ View ]

Patch doesn't work for me either.

problem comes from defaults.src[defaults.src.length-1], my array hasn't a key integer but the value string as key.

So this is a patch which work for me (and make sure to return string)

This patch is part of the #1day1patch initiative.

Status:Needs review» Reviewed & tested by the community

This looks good to me.

Status:Reviewed & tested by the community» Needs review
StatusFileSize
new1.04 KB
PASSED: [[SimpleTest]]: [MySQL] 914 pass(es).
[ View ]

I used the patch in #19 in single field CKEditor. The patch works some predefined number of times and then starts to generate: "call to missing method replace on undefined" errors in the browser's console.

After some digging, the issue is that the 'shift' method removes the value from the defaults, and inevitably at some point the array goes empty, resulting in the issue described.

Adding a patch, based on the one in #19, but after the shift method, returns the value back with unshift, this prevents the array from getting empty.

Re-rolled the patch against revision 8798bfcd24501959fc024e9b7a9b52fec98fc1d8.

#21 fixes the problem for me in 7.x-2.0-alpha2

Issue summary:View changes

environnement

using media 7.x-2.0-alpha3 and #21 doesn`t helped, still get this error in console: ~format-form?render=media-popup&fields=undefined
Any other ideas how to fix it?

This is a patch against revision 2283c03, I need this NOW!

I have a similar problem. Uploading an image freezes the GUI (Browser). The image is uploaded to the server, but it never appears in any gallery. Someting is plain wrong here.

Status:Needs review» Reviewed & tested by the community

I was having the same issues when using ECK fields. #21 sorted it out for me on 7.x-2.0-alpha3.

Status:Reviewed & tested by the community» Patch (to be ported)

Still experiencing this in media 1.4 and panels => add custom content into a page
I'm having exactly the same issues as in #11 with following JS error

Uncaught TypeError: Object [object Array] has no method 'replace'

The version of this needs to change to 1.x since commited to 2.x, right?