Prevent wrapping P tag in TinyMCE editor



How do I remove/prevent TinyMce to wrap my Imagevault tag in a p tag?

Now im getting the following html:

But I want this:

Mar 17, 2015 15:40

Im using EPiServer 7.1 btw.

I found the following code but where do I put it? Can I pass some options in a attribute on the property perhaps?

      mode : "textareas",
      theme : "advanced",
      force_br_newlines : false,
      force_p_newlines : false,
      forced_root_block : '',
Edited, Mar 17, 2015 15:42
Mar 17, 2015 19:03

Thanks! Will try that tomorrow. I've tried the following today, im just courious why this doesn't work?

I created a custom EditorDescriptor and decorated my property with it. Then in my EditorDescriptor I did the following:

public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
            var model = (PropertyData) metadata.Model;
            var settings = (TinyMCESettings)(model).GetSetting(typeof(TinyMCESettings));
            var options = new TinyMCEInitOptions(TinyMCEInitOptions.InitType.EditMode, settings, (IContent)null);
            options.Add("forced_root_block", string.Empty);
            metadata.EditorConfiguration["settings"] = options.InitOptions;
            base.ModifyMetadata(metadata, attributes);

I can see all the options when debugging but I get a 500 error when loading this in Edit mode.
Can update tomorrow with a more detailed error.

Edited, Mar 17, 2015 22:08

Jonas, your solution worked, but now Im not getting any p tags wrapping my text(obviously).

Do you guys know any setting that just prevents wrapping a img element with a p tag?

I could use regex to remove it but that's really ugly...

Edited, Mar 18, 2015 9:09


i used two solutions for this problem

1. went to the tinymce file and in the appdata ( in the zip ) added the force_br_newlines false also added alot of other issues and zipeed again and it worked 

use the a dev toolbar to get the file location

this is the hammer approch

2. after i got helped from the support you need to create a plugin to tinymce and set the values 

this is the default add the one you need, also you need to write the same as the example ('' and , ) if not all the cms ui stops working

AlwaysEnabled = true,
PlugInName = "NonVisualPlugin",
DisplayName = "Custom editor init options",
Description = "Loads custom editor init options.",
EditorInitConfigurationOptions = @"{
paste_auto_cleanup_on_paste : true,
convert_urls: false,
valid_elements : ""a[href],strong/b,em/i,br,ul,ol,li,-h2,-h3,-h4,-h5,-h6,-p"",
theme_advanced_blockformats : ""h2,h3,h4,h5,h6,p"",
theme_advanced_resizing : false,
body_class : ""module-text""

public class NonVisualPlugin


You also need to create the a blank javascript file named editor_plugin.js at this location:



Mar 18, 2015 9:27
* 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.