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.
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 ?
Comments
Comment #1
cedric CreditAttribution: cedric commentedThe bug is also present on 7.x-1.2
The javascript error was:
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?
Comment #2
cedric CreditAttribution: cedric commentedComment #4
cedric CreditAttribution: cedric commentedproper patch
Comment #5
cedric CreditAttribution: cedric commentedComment #6
stefgosselin CreditAttribution: stefgosselin commentedAmazing! Patch in #4 made my day. Tested and approved.
Comment #7
stefgosselin CreditAttribution: stefgosselin commentedComment #8
aaron CreditAttribution: aaron commentedI 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.
Comment #9
ParisLiakos CreditAttribution: ParisLiakos commentedpatch also contains 3 white spaces
Comment #10
ParisLiakos CreditAttribution: ParisLiakos commented#1630288: Upload image freeze on wysiwyg integration with multi field media seems duplicate
Comment #11
brunodboSimilar 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:
Comment #12
gmclelland CreditAttribution: gmclelland commented@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?
Comment #13
brunodboJust tested it on a fresh install of everything, and indeed, all seems good. #11 is invalid, sorry for the noise.
Comment #14
designar CreditAttribution: designar commentedI've experienced the same issue on the latest media module in a panopoly installation.
The patch from #4 helped to fix the problem.
Comment #15
John Pitcairn CreditAttribution: John Pitcairn commentedI 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:
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.
Comment #16
John Pitcairn CreditAttribution: John Pitcairn commentedThis 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).
Comment #17
John Pitcairn CreditAttribution: John Pitcairn commentedComment #18
MiroslavBanov CreditAttribution: MiroslavBanov commentedThe 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"
Comment #19
GoZ CreditAttribution: GoZ commentedPatch 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.
Comment #20
aaron CreditAttribution: aaron commentedThis looks good to me.
Comment #21
ndobromirov CreditAttribution: ndobromirov commentedI 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.
Comment #22
ndobromirov CreditAttribution: ndobromirov commentedRe-rolled the patch against revision 8798bfcd24501959fc024e9b7a9b52fec98fc1d8.
Comment #23
ianthomas_uk#21 fixes the problem for me in 7.x-2.0-alpha2
Comment #23.0
ianthomas_ukenvironnement
Comment #24
lanzs CreditAttribution: lanzs commentedusing 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?
Comment #25
dagomar CreditAttribution: dagomar commentedThis is a patch against revision 2283c03, I need this NOW!
Comment #26
WMarkus CreditAttribution: WMarkus commentedI 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.
Comment #27
mike.davis CreditAttribution: mike.davis commentedI was having the same issues when using ECK fields. #21 sorted it out for me on 7.x-2.0-alpha3.
Comment #28
aaron CreditAttribution: aaron commented21: media-js-error-on-wysiwyg-with-multi-field-1630288-21.patch queued for re-testing.
Comment #29
aaron CreditAttribution: aaron commentedCommitted to http://drupalcode.org/project/media.git/commit/cdd67b4
Comment #30
webatelier CreditAttribution: webatelier commentedStill 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'
Comment #31
hefox CreditAttribution: hefox commentedThe version of this needs to change to 1.x since commited to 2.x, right?
Comment #33
joseph.olstadThis was fixed by @aaron a while back, RIP good fellow!