1
votes

I am using Tinymce as an email editor. When inserting an embedded image as attachment, the images are inserted as:

<img src="cid:mycid@sth" />

This works for the email sending part - but of course not for the editor. The image is not displayed...

Question: Is there a "content" and "display" layer in Tinymce where I can hook into?

My goal is to save the content as

<img src="cid:mycid@sth" />

and transform it in the editor window as

<img src="/mypreview/image/2000" />

I am using Tinymce 4.

1

1 Answers

1
votes

The editor relies on the browser for the rendering of HTML so anything like your <img src="cid:mycid@sth" /> won't render in the editor - its simply not valid HTML.

What you can do is rely on data-xxx attributes in HTML to store the data you really want and transform the HTML when you go to load it into TinyMCE.

For example...

When someone inserts the image you could create the following HTML

<img data-src="cid:mycid@sth" src="/mypreview/image/2000" />

...this would allow the editor to actually render an image while you still keep the data you need. When you save the content you can strip out the existing src data and copy the data-src content back into the src if that is what your app needs for its server side processing.

If someone edits the content you can just reverse the process and change the src back to HTML that TinyMCE can render.