November Happy Hour will be moved to Thursday December 5th.

Display image as block in TinyMCE

Vote:
 

When I drag an image into a content area it gets rendered using a template located at /Shared/DisplayTemplates/. When I drag a block into the TinyMCE editor it gets rendered using its template. When I drag an image into the TinyMCE editor it doesn't get rendered with the template located at /Shared/DisplayTemplates.

Is there a way to achieve this? Or another way to alter the way an image is rendered when added with the TinyMCE editor?

#86190
May 15, 2014 15:20
Vote:
 

What model do you have in your displaytemplate? 
Can you write the code here?

#86193
May 15, 2014 15:46
Vote:
 

Nothing more magical than

@model EPiServer.Core.ContentReference
@if (Model != null)
{
    <img src="@Url.ContentUrl(Model)" />
}

The problem isn't the template, but the fact that images are handled different than blocks by the TinyMCE editor.

When you drag a block into TinyMCE it gets handled like this:

https://s3-eu-west-1.amazonaws.com/uploads-eu.hipchat.com/27490/171745/yMYtJ7a4nlRqBrl/upload.png

But images are handled like, well, images. I want them to be handled like blocks.

#86199
Edited, May 15, 2014 16:26
Vote:
 

I think you might have to specify two displaytemplate, one for mediafile like this (http://tedgustaf.com/blog/2014/4/render-image-properties-in-episerver-75/) and one for the old way since it seems like it is handle the old way in TinyMCE.
I have not been able to try it myself, but will do soon.

#86201
May 15, 2014 16:37
Vote:
 
#86202
May 15, 2014 16:37
Vote:
 

Seems to be exactly what I'm looking for, Per Magne. Thanks!

#86205
May 15, 2014 16:41
Vote:
 

Thanks Per Magne, now I know what to do.

#86207
May 15, 2014 16:48
Vote:
 

You're welcome!

#86216
May 15, 2014 18:28
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.