Wysiwyg-editor: File/Image Upload Dynamic URL

Created on 28 Jun 2016  路  5Comments  路  Source: froala/wysiwyg-editor

I'm not sure if this is possible with the event file.beforeUpload? Thoughts on how you would handle this for Froala? It's pretty critical for our current use.

Expected behavior.

If a function is passed to the imageUploadURL or fileUploadURL then call that function to dynamically return the url each time.

Actual behavior.

only accepts a string

Steps to reproduce the problem.

N/A

OS.

N/A

Browser.

N/A

feature-request

Most helpful comment

Really looking forward to this feature, because I'd like to use clientside code to resize, compress and get Exif datas of images before uploading.

For now I'm trying to use this event:

$('.selector').on('froalaEditor.image.beforeUpload', function (e, editor, images) {
// Do something here.
});

But I don't know if I can return _modified_ files? The docs only say we can return false to abort upload.

All 5 comments

Here's my "solution". I'd be interested to hear your thoughts on it.

opts = {
  fileUploadURLFunc = function (return '/api/' + this.container().id + '/files';),
  ...
};

this.element.on('froalaEditor.file.beforeUpload', function(e, editor, files) {
 editor.opts.fileUploadURL = editor.opts.fileUploadURLFunc(); 
}).froalaEditor(opts);

This seems to do the trick, but it feels odd to have to set an internal option before each upload. What are your thoughts on accepting a function as the value for fileUploadURL and imageUploadURL and then at runtime doing something like:

var uploadURL = typeof editor.opts.fileUploadURL === 'function' ? editor.opts.fileUploadURL() : editor.opts.fileUploadURL;
....

We are working on a feature to allow premises for image upload options and that will be available shortly. We use this repo mainly for bug tracking, therefore please contact us via our website for any feature request or tech question. 馃槃

Will do. I really appreciate your feedback. It's been invaluable to us over the last few weeks! Keep up the good work! 馃憤

Really looking forward to this feature, because I'd like to use clientside code to resize, compress and get Exif datas of images before uploading.

For now I'm trying to use this event:

$('.selector').on('froalaEditor.image.beforeUpload', function (e, editor, images) {
// Do something here.
});

But I don't know if I can return _modified_ files? The docs only say we can return false to abort upload.

We've just put together a public roadmap with the most popular features. 馃槏 There you can vote your favorite one, provide feedback or make new suggestions: https://wysiwyg-editor-roadmap.froala.com/public.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

homoky picture homoky  路  3Comments

Krisell picture Krisell  路  3Comments

bbugh picture bbugh  路  3Comments

archonic picture archonic  路  4Comments

DerekJDev picture DerekJDev  路  3Comments