Is it possible to override how a URL is rendered in TinyMCE with DisplayTemplates?

Member since: 2010

I've tried creating all of the Modules/CMS/Util/Views/DisplayTemplates that seemed logical to be called for rendering of a URL inside TinyMCE. Is none of these being called?

What I am trying to do is to change the rendering for GenericMedia added as document link in TinyMCE. I can ofc, replace the content using HtmlAgilityPack, but I am wondering if there is a better approach.

#87406 Jun 12, 2014 15:39
  • Member since: 2009

    The default behaviour for dropping IContentMedia in TinyMCE is to create a link. This should be overridable by creating a custom UIDescriptor that tells the editor to create content blocks. This will mean that the display template will be used for rendering instead.

    [UIDescriptorRegistration]
    public class GenericMediaUIDescriptor : UIDescriptor<GenericMedia>, IEditorDropBehavior
    {
        public GenericMediaUIDescriptor()
        {
            EditorDropBehaviour = EditorDropBehavior.CreateContentBlock;
        }
    
        public EditorDropBehavior EditorDropBehaviour { get; set; }
    }

    The above code will work for the GenericMedia in the alloy template. You won't get the display template used in TinyMCE it will probably just look like a dynamic content but it should display correctly on the page.

    PS: I haven't tested the above.

    #87568 Jun 17, 2014 11:41
  • Hi, having the same issue as Marija and she directed me to this thread from my question (http://world.episerver.com/forum/developer-forum/-EPiServer-75-CMS/Thread-Container/2015/5/get-episerver-settings-on-image-for-external-resources)

    I just wonder when it's an image that is to be presented is there any way of being able to control settings for the content displayed? The image just gets added to the editor without any way of changing something on it. In my example the content is based on content read from an external PIM system and the resulting presentation is based on that PIM systems built in ImageLoader. This loader has the possibility to add width and height to the url and it would be great if that could be controlled by the editor when adding the content to the page.

    #121453 May 11, 2015 16:03