See also http://drupal.org/node/183216
Here is a patch for 6.x-1.2-91

CommentFileSizeAuthor
yui_editor-6x-12-91_addimageupload.patch6.21 KBAnonymous (not verified)

Comments

rovo’s picture

will this be included in the next release? Not really sure how to add patches.

Anonymous’s picture

Error message after uploading files

In Drupal 6.x there is an error message after uploading images using the patch above.

To fix this, replace line 214 in yui_editor.module with the following:

$file = file_save_upload('upload', array(), $path, FILE_EXISTS_REPLACE);

Drupal 6 added an extra parameter to the functioncall.

gustavlarson’s picture

Great work!

However I found a few issues except the one that you mentioned.
I have my development site installed under localhost/drupal.
However the POST made by the image upload is made to localhost/yui_editor/image_upload, when it should be localhost/drupal/yui_editor/image_upload
The response sent back to the browser also contains the wrong path.

Perhaps a minor issue, but you could wrap the text in the javascript file in Drupal.t() to make them translatable.

gustavlarson’s picture

Another minor thing. I think it would be a lot better not to replace the old file if a file with the same name exists, but to rename the new one. You can not expect your users to know what filenames are already in use, and cause a lot of confusion.

Change the line

$file = file_save_upload('upload', array(), $path, FILE_EXISTS_REPLACE);

to

$file = file_save_upload('upload', array(), $path, FILE_EXISTS_RENAME);
Anonymous’s picture

@#4: I agree with you. I choose to overwrite to prevent getting multiple copies of the same image. This happens when you use the image in several places or make changes to it after uploading. But this is less important, so for now I'll settle for FILE_EXISTS_REPLACE.

In the meantime I'll have a look at other options. I could think of the following (in order of complexity):

  • add an extra admin setting to choose between Overwrite and Replace
  • ask the user what to do if an image with the same name exists
  • use one of the existing image modules for better image handling
Anonymous’s picture

@#3: I'm glad you like it.

About your issue:
The prefix of the post is created by Drupal core. All I put in the module is yui_editor/image_upload which in my case results in the URL: http://www.myserver.nl/yui_editor/image_upload. As far as I know this is not different from any other Drupal module behaviour. (I copied the code from the upload module). I suggest you have a look at the $base_url setting in the settings.php file of your development site. This should be something like localhost/drupal in your case. An even better solution would be to create a virtual server for your development site if possible in your environment.

jeffcd’s picture

Status: Needs review » Closed (fixed)

This has been set and released in 2.9.94. Test and let me know. Thanks.