Skip to content

TinyMCE - paste image - editor.uploadImages() #1361

Closed

Description

@itg-assistant

Dino Novak asked 2018-02-08 14:30:20 UTC

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

Activity

  1. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Dino Novak answered 2018-02-08 19:54:12 UTC

    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

  2. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2018-02-08 21:56:52 UTC

    There isn’t anything different in Wisej. You have to setup a handler for the uploaded images.

  3. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2018-02-08 22:01:16 UTC

    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.

    
    
  4. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Dino Novak answered 2018-02-09 11:08:49 UTC

    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

  5. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2018-02-09 15:02:37 UTC

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    GeneralQuestions, how-tos and everything else.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions