Download & Extend

Body text gets lost when using fupload and wysiwyg API

Project:Wysiwyg
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (won't fix)

Issue Summary

I am using fupload on an imagefield.
When creating a new node, I enter my body text and then upload images via fupload. I click on "Next step" and get redirected to the edit captions page. After clicking "Done editing", my body text is lost and I am only seeing the images on my node. However, this only happens when I use WYSIWYG API (in my case with TinyMCE editor, I didn't try other editors).
As WYSIWYG API is ranked among the 30 most used modules, it would be great if that issue was resolved. I tried to figure out what exactly is going wrong, but I wasn't successful so far.

Comments

#1

As you can see, the issue queue is quite long at the moment.
Because FUpload is fully based on Drupal's Ajax functions to be able to retrieve the data from the fields, WYSIWYG is not fully compatible to that.
So, it's not only fupload's fault.
I don't have much time at the moment, please provide patches. I will concentrate on checking and submitting them.

#2

+1. This would be great as it is extremely frustrating having to re-enter any body content.

#3

Subscribe. Having the same issue. Will try to find source of problem.

#4

Subscribe.

#5

Seeing this happen with current (DRUPAL-6--2) version of FCKEditor as well.

This is a relatively new phenoma

#6

This issue has affected WYSIWYG with TinyMCE for about a year now.

#7

grandcat suggests that the issue lies with the visual editor (WYSIWYG/FCKeditor) rather than image_fupload. I created an issue under the fckeditor project:

http://drupal.org/node/653718

I say this is a recent phenomena with FCKeditor as my site was working fine up until a few weeks ago (not exactly certain of the time). I've no experience with WYSIWYG w/r/t this issue.

#8

@toddgee: I think it is very unlikely that the issue lies with the WYSIWYG editor itself, because the problem exists with TinyMCE as well and isn't present in Wordpress, which uses a similar combination of flash upload technology and TinyMCE.
The issue is probably caused by the way Drupal integrates WYSIWYG editors in general or by flash upload. I doubt it is caused by a certain WYSIWYG editor.

#9

It's a conflict in the load procedure of FUpload and all other editors.
If someone has the time, a patch would be very helpful.

#10

This is a great module. I would be willing to contribute a bounty if someone can fix this issue. Also willing to help design UI.

#11

subscribing

#12

Tried CKeditor and there this problem is missing :-)

(http://ckeditor.com/download)

#13

I can't confirm the problem is gone when using CKeditor.

@deepM: Are you using CKeditor with the Wysiwyg module or are you using the seperate CKeditor module? This issue is about incompatibilities with the Wysiwyg module. So, if you are using Wysiwyg, could you tell us about all your settings for Wysiwyg and CKeditor? Maybe that will help to finally track down the problem.

#14

I just tried migrating from using the fckeditor module to the ckeditor module on the site that prompted me to weigh in on this issue (post #5). I'm no longer seeing the problem.

Again, this is using the CKeditor module (tag: DRUPAL-6--1) on a fully patched Drupal 6 site (tag DRUPAL-6)

#15

Oh sorry, didnt use WYS... module, just CKeditor. I did have problem with FCK editor before, also without WYS...

#16

Project:Image FUpload» Wysiwyg
Version:6.x-3.0-rc2» 6.x-2.x-dev

Never mind! Actually, your information may also be very useful for users of WYSIWYG API. The fact that it is working with CKeditor module, but not with FCKeditor module (which are very similar) proves two very important things:

a) The problem can be solved without any changes to ImageFupload
b) The problem can (and therefore probably should) be solved by the wysiwyg editor modules

Users of the FCKeditor module now have a good solution by using CKeditor module instead, which is the successor of FCKeditor anyway.

However, there is no such solution for users of the WYSIWYG API module. Thus moving this issue to WYSIWYG API module issue queue.

#17

Status:active» postponed (maintainer needs more info)

I am unable to reproduce this issue with Wysiwyg and TinyMCE, CKEditor or FCKeditor.

  1. I set image_fupload to attach multiple images to a single node (via imagefield). Setting it to create multiple nodes per image just hid the body field without saying why (a wtf on its own, IMHO), so no editor is available in that case.
  2. typed some content into the body of a new node with an editor active
  3. selected/queued a few images
  4. uploaded them with the "Save" button.
  5. clicked "Next stage" button
  6. typed in image descriptions, saved
  7. got redirected to the saved node which has all the content I addded
  8. I need the exact steps to recreate the circumstances where the body content is dropped when clicking the "Next step" button on a new node.

    The only case where I see dropped body content is if I edit an existing node, add some more images using image_fupload and then hit "Next stage". In that case the button simply changes redirects to the new page without ever posting the node form, so there's nothing Wysiwyg module can do about that without completely overriding that button's click handler.
    (I'm actually considering filing a usability issue for image_fupload, as one would expect the 'Next stage' button to submit the form this time as well.)

#18

Status:postponed (maintainer needs more info)» active

Thank you very much for looking into this, TwoD!!

I just invested several hours of testing on a fresh and clean Drupal 6.16 install. The problem is still present and reproduceable if a wysiwyg editor is enabled on the body field. So let me provide some more details.

I didn't change any of Drupal's default settings.
Besides Wysiwyg I installed/enabled the latest versions of the following modules to get image_fupload running on an imagefield:

  • Content (CCK), 6.x-2.x-dev
  • Filefield, 6.x-3.x-dev
  • Image FUpload (CCK), 6.x-3.x-dev (with SWFupload v2.2.0.1 Core)
  • ImageField, 6.x-3.2
  • ImageAPI, 6.x-1.x-dev
  • ImageAPI GD2, 6.x-1.x-dev
  • Imagecache, 6.x-2.x-dev
  • ImagecacheUI, 6.x-2.x-dev
  • Image FUpload, 6.x-3.x-dev
  • Transliteration, 6.x-3.x-dev
  • Wysiwyg, 6.x-2.x-dev (with TinyMCE 3.3.2)

There are no other contrib modules installed!
I did not change any settings of Wysiwyg besides assigning TinyMCE to the default input format.

These are the exact steps I took to reproduce the problem:

  1. Created an Imagecache preset that scales the images to say 400x300
  2. Created an imagefield on Drupal's default Story content type. (Field type: file; Widget type: Image FUpload)
  3. In the settings of the newly created imagefield:
    • Set storage mode to "Multiple images per node".
    • For the setting "Preview Image Preset" selected the Imagecache preset I have created in step 1.
    • Selected "Unlimited" for "Number of values".
    • Left all other settings unchanged and saved the imagefield.
  4. Created new Story
  5. Typed something in the body field, with TinyMCE active!
  6. Selected several images using image_fupload
  7. Clicked the Save button. (image_fupload starts uploading the images)
  8. Clicked "Next step"
  9. Got redirected to the Edit Captions page (there are no fields to enter something, because I did not enable them in step 3
  10. Clicked "Done editing"
  11. Got redirected to the saved node.
  12. Bam! Body text is gone, images are there!

Note that there is absolutely no problem as long as TinyMCE (or any other editor) is NOT active in step 5!

What puzzles me is the fact that the steps I took to reproduce the problem read very similar to the steps you described in #17. But I can try over and over again, I always end up with no body text when a wysiwyg editor is enabled on the body field.

#19

Well i have messed arround with a bug today which could be related today. Upload.module with the AHAH file upload seems to background-submit the whole form. What happens then is, that the onbeforegetcontent handlers are fired of the WYSIWYG-editors, because well the form is submitted.

While the WYSIWYG module is more clever and binds its event to the submit button, those events are anyway fired. So most of the plugins handling wyswiyg module evens might work, but there is a possibility that editor intern modules still fire on the editor specific beforeContentGet events.

In my case the editors round-robbin feature gets weared and my body is not correctly formatted, because i have an old plugin listen on the editor events directly ( tinyMCE editor).

Not sure this helps here, just thought that this can actually be related.

Also i encountered some strange issues with memcache + ajax calls ( could be APC related ). So if you both use memcache or APC try it without, there are some strange things concerning those with the current D 6.x core.

#20

EugenMayer, thank you very much for your help.

Upload.module is not active in my case, but maybe image.fupload uses a similar functionality!?

On the other hand it's strange that CKeditor does not cause any problems, but Wysiwyg API does. This is why I think this is more likely related to Wysiwyg than to image.fupload

#21

Wouldnt bet on that.

Maybe the CKeditor does not register internal onbeforecontentget handlers or they are not critical enaugh. TinyMCE is a beast anyway, so i pretty expect something to break there. If you wont a advice, dont use tinyMCE. After ~4 years of usage iam burning to get a way. And i will do so after portining the old plugin to the WYSIWYG api.

Back to the topic, it could depend on the editor, as those handlers are editor specific and actually installed on the edit-textfield

#22

Actually, it does not matter which editor I use, as long as I do it in combination with Wysiwyg API.

I was refering to the CKeditor module and this does not cause any issues. However, if I use CKeditor together with Wysiwyg API it is not working and I am losing the body text again. This is why I thought this could likely be related to Wysiwyg API.

#23

Subscribing - would love to see the conflict here get solved! Current workaround for me is saving nodes with images first, then creating the text and saving again

#24

Same problem here! I tried hard to find out what exactly is causing the problem, but I wasn't able to figure it out. Nevertheless, I still agree this looks like there is something wrong with the wysiwyg module.

#25

I'm still unable to reproduce the problem using the procedure and module versions from #18 using FF 3.6.3.
Each time I upload images to the imagefield using Image FUpload and click "Save" then "Next step" and finally go to the rendered node, it's all intact.
IE (8) acts weird altogether and wants to download a file after all images have been uploaded, and it completely ignores the uploaded images after that, so I've not been able to complete the tests using that browser.

Fupload module's code (or at least the part dealing with imagefields) doesn't seem very Drupal friendly so I would actually expect all kinds of things to go wrong with a number of other modules as well.
First, it overrides window.onload without respecting any previously assigned handler. This does not affect Wysiwyg module directly, but may cause problems for other modules.

When "Save" is clicked after selecting a couple of images, the Flash part of SWFUpload seems to take the whole form and submit it in the background, to which the editors react (their onsubmit handlers get called, causing them to sync their contents back to the original textarea). Wysiwyg doesn't react as the form's real "Save" button wasn't the one clicked, but a replacement for it created by image_fupload. That first part is what saves whatever I type into the editor - before uploading any images - to the database.

When the "Next step" buttons/links are clicked, image_fupload blindly does a brutal window.location = url without ever submitting the form again. Any changes made to the body field (or almost anything else for that matter) after uploading images are always lost, regardless of an Wysiwyg's state. As the form is not submitted - or its original buttons clicked - Wysiwyg module has no part in what happens when the "Next step" is taken. Nor should it need to, considering it's a GET request which itself should not change anything on the server.
All the editors do at this point is to run their cleanup methods to prevent memory leaks (mostly in IE). There would be no point for them to sync their contents with the original field as no POST is being made. Normally, their onsubmit handlers would have fired before this, if it the user intended for changes to be saved.

To summarize: IMHO, the way image_fupload[_imagefield] works is flawed. It should follow Drupal's conventions regarding how "onload" code is run, via Drupal.behaviors to avoid the risk of interfering with, or being disrupted by, other scripts running on the document. (The amount of code added to the header is also quite large, I'm sure there would be a way to break it out into an external script during the transition to Drupal.behaviors.)
Image FUpload needs to be rewritten so that an actual POST is made once "Next Step" is clicked, by turning it into an actual submit handler that redirects to the step between uploading and seeing the created node. As soon as that is accomplished, any module relying on the form being properly submitted will have a much easier way to integrate with the module. It would also allow users to change any field after images have been uploaded.

#26

TwoD there is no need to rewrite image_fupload - just use swfupload :) Muuuch better!

Thanks for the inverstigation!

#27

You mean this new module?

http://drupal.org/project/swfupload

i will try it, been long time with fupload, never liked it, from its icon to workflow from all this other problems, hope this one works better!

#28

@27 yes and it works a lot better.

#29

Well i did try it but having problems with installation, grey button issue, will work on it but its seems its very beta that module.

#30

See in the fixed issues and patch it :)

#31

swfupload looks nice but there's a bunch of pending patches to fix quite a few issues. Seems it's still a couple months away from being there

#32

I'm also suffering from this problem. Drupal (pressflow) 6.16 with Wysiwyg + CKEditor + image fupload.

Right now, the workaround is to load the gallery first, then write the content.

#33

@31: image_fupload is tagged stable but can be seen as alpha.

#34

I just came across this problem and I was very surprised that the combination of wysiwyg and fupload didn't work, because I did the same thing on another project a week ago and it worked..

after trying all kind of things for several hours I found out why it worked on the first project, but not on the second:

If you have just one uploadfield and its fupload it won't work.
If you have two uploadfields, one being a simple imageuploadfield and the other a fupload it will work if you first upload an image with the simple uploadefield and then select the images you won't to upload with fupload..

I don't know if this may help solving the problem, but I hope so ;)

#35

Status:active» closed (won't fix)

Given TwoD's excellent summary, and the fact that swfupload module has been reported to work, this sounds like a bug in fupload module.

#36

subscribing. Same here. Any updates??

For now i just provide instructions on content types that experience this bug to first upload the pictures and leave the body blank, then come back in to edit the node and add the body. This works for now, but makes the module seem silly (however it's extremely powerful and i appreciate your work on this module).

#37

I implemented the SWFUpload module instead and am delighted to say that it works perfectly so far. Solves this issue for me. I'll be using SWFUpload from now on instead of Image FUpload. Thanks!!!

nobody click here