Wysiwyg-editor: New option for image upload

Created on 27 Oct 2016  路  4Comments  路  Source: froala/wysiwyg-editor

From Docs -

The server has to process the upload request, save the image and return a JSON containing a link to the uploaded image. The returned JSON needs to look like: { link: 'path/to/image.jpg' }

Can we have another imageLink option to replace fixed json. if imageLink options is used then froala should look for image url in that option instead of "link" key in json.

enhancement

Most helpful comment

Please provide ability to normalize server response (via option or image.uploaded event).

All 4 comments

What you can do is to use the image.uploaded event, parse the response and insert the image using the image.insert method.

When I do it, I see two pictures in editor:

<p>
  <img class="fr-dib fr-draggable" src="//my-server.org/5efe9e3135d600d02052f64fd3687c0e.png" style="width: 300px;">
  <img class="fr-dib fr-uploading fr-draggable" src="blob:https://localhost:4200/6d6653c3-6583-4bcb-a547-3529437edd5e" style="width: 300px;">
</p>

"ember-froala-editor": "2.3.6-beta.2",
"froala-wysiwyg-editor": "2.3.5"

Please provide ability to normalize server response (via option or image.uploaded event).

Is it possible to get a hook function to customize the server response before Froala try to insert the ressource? With this feature, we could use any image hosting SAAS without creating a proxy server side to customize the server response.

Currently, I need to create a dirty trick 馃憥 by overriding JSON parse:

// patching `parseJSON` because Froala doesn't allow customization of response
// To update for 2.6.3+ to use JSON.parse instead of Jquery.parseJSON (https://www.froala.com/wysiwyg-editor/changelog#2.6.3)
var _parseJSON = jQuery.parseJSON; //var _parseJSON = JSON.parse;
jQuery.parseJSON = function(j) { // JSON.parse = function(j) {
  var response = _parseJSON(j);
  if (response.link === undefined && response.url !== undefined)
    response.link = response.url;
  return response;
};
Was this page helpful?
0 / 5 - 0 ratings

Related issues

CrazyClicker picture CrazyClicker  路  4Comments

adilsonb picture adilsonb  路  3Comments

kikeso77 picture kikeso77  路  3Comments

bnjmnfnk picture bnjmnfnk  路  4Comments

Krisell picture Krisell  路  3Comments