jsonDoge
jsonDoge

Reputation: 722

Tinymce imagetools image not showing

so I started using tinymce for my blog posts and there is this problem with imagetools, they work while images are being edited, but after the article is posted, only this BIG url is showing. I think the problem is that, the blob image which is created while editing is not saved and I need to save it, right?

By the way I am using laravel.

Upvotes: 0

Views: 4329

Answers (1)

Michael Fromin
Michael Fromin

Reputation: 13744

When you edit images using the image tools they will always be turned into a Base64 or BLOB encoded image - the image tools function in the browser and know nothing (directly) of the application in use (e.g. Laravel). As such its up to the application to determine what to do with these images:

https://www.tinymce.com/docs/advanced/handle-async-image-uploads/

The basic process is that TinyMCE will create a separate HTTP POST for each image that you modify with the image editor. It will send that image to a URL of your choosing (via HTTP POST) based on the setting of the images_upload_url option in your init.

The image handler at the URL referenced in the images_upload_url (which you have to create) has to do whatever needs to be done to "store" the image in your application. That could mean something like:

  • Store the item in a folder on your web server
  • Store the item in a database
  • Store the item in an asset management system

I would assume Laravel has some APIs such as the Filesystem API that you could use to store the images appropriately.

Regardless of where you choose to store the image your image handler needs to return a single line of JSON telling TinyMCE the new location of the image. As referenced in the TinyMCE documentation this might look like:

{ location : '/uploaded/image/path/image.png' }

TinyMCE will then update the image's src attribute to the value you return. If you use the images_upload_base_path setting in the init that will be prepended to the returned location.

The net here is that TinyMCE knows when an embedded image exists in your content but it can't possibly know what to do with that image in the context of your application so that job (the "image handler") is something you must create.

Upvotes: 2

Related Questions