N
N
nickmernin2014-08-04 15:32:10
JavaScript
nickmernin, 2014-08-04 15:32:10

[Rails] How to make image loading in WYSIWYG Redactor (imperavi.com)?

The question is in the title. Actually, when saving content, it translates pictures into base64 and tries to save them in the database.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Krasnodemsky, 2014-08-04
@Prognosticator

https://github.com/SammyLin/redactor-rails

A
Artem Spiridonov, 2014-08-04
@customtema

Make a separate file uploader. Requirements for it:
- on the server - checking permissions, checking MIME, anti-XSS
- on the server, optionally - converting images, generating and saving thumbnails
- returns the parameters of the loaded in AJAX
Write a small script that will catch the response from the loader on the client, and insert pictures or links in the editor.
Example for CKEditor with jQuery:

if (response.is_image)
  {
    var thumb_name = response.file;
    var full_name = thumb_name.replace('_thumb','');
    $(response.editor).ckeditorGet().insertHtml(' <a href="' + full_name + '" target="_blank" class="dialog"><img src="' + thumb_name + '" border="0"></a> &nbsp; ');
  }
  else
  {
    $(response.editor).ckeditorGet().insertHtml(' <a href="' + response.file + '" target="_blank" rel="gallery">' + response.filename + '</a> <br /><br />');
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question