TinyMCE - paste image - editor.uploadImages()

Welcome to Wisej Support.
Questions, suggestions and plain old bugs - are all welcome here!
0
0

HI,

I am looking for functionality to allow user to paste image to TinyMCE content.

There is editor.uploadImages() function and I wonder if anyone managed to make it work.

Any suggestions how to do it from Wisej?

Thanx,

DiNo

  • Dino Novak
    Also is there any TinyMCE sample. How do you include this startup items and customize it? tinymce.init({ selector: ‘textarea’, // change this value according to your HTML plugins: ‘code’, toolbar: ‘code’ }); Regarding the Upload functionality it is defined here for TinyMCE https://www.tinymce.com/docs/get-started/upload-images/ How to define Upload in Wisej
  • Luca (ITG)
    There isn’t anything different in Wisej. You have to setup a handler for the uploaded images.
  • You must to post comments
0
0

Hi Dino,

I have attached the fixed project. These are the errors:

  • Didn’t enable the image plug in, you need to add “plugins”:”image”, see: https://www.tinymce.com/docs/plugins/image/
  • The return string was incorrect, it didn’t have the $ prefix for interpolated strings; the placeholder {file.FileName} was never replaced, see my code in the previous post.
  • The project didn’t have the “images” directory so saving the file generated an exception.

HTH

/Luca

  • You must to post comments
0
0

Hi,

Please find attached sample with http handler defined and options set. But I am not able to get http handler firing ?

When you drag or paste the inage TinyMCE converts it to Base64 and keeps it in the HTML content, but i would like to avoid this.

Can you help please, feel free to upload it to examples when you manage to fix it , we should save time and nerves for others.

Regards,

D

  • You must to post comments
0
0

More here:

https://www.tinymce.com/docs/get-started/upload-images/

I have added this to the options

    "images_upload_url": "TinyMCE-ImageUpload.ashx",
    "images_upload_base_path": "/images"

and added a simple handler:

public class TinyMCE_ImageUpload : IHttpHandler
 {
 public void ProcessRequest(HttpContext context)
 {
   var request = context.Request;
   var response = context.Response;
   if (request.Files.Count > 0)
   {
     HttpPostedFile file = request.Files[0];
     var filePath = "images/" + file.FileName;
     using (var image = new FileStream(request.MapPath(filePath), FileMode.Create, FileAccess.Write))
     {
        file.InputStream.CopyTo(image);
     }
     response.Write($"{{\"location\":\"{file.FileName}\"}}");
   }
  }

  public bool IsReusable
  {
    get { return true; }
  }
 }

There are of course many options and variations. It’s just plain asp.net or mvc handlers. You can also use a php handler on the server.

 


            
  • You must to post comments
Showing 3 results
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Attachment
File Name Size
There are currently no files uploaded.
Maximum number of files 5, maximum file size 3.9MB.
Supported file formats: zip pdf gif jpg bmp png cs vb theme json mixin.theme