Try our conversational search powered by Generative AI!

Disable Html Editor auto code cleanup


I have a page with xhtml property and whenever I put an img src="" and publish the page, it cleans up the URL and modifies it to img src="/global/myimage.png" which makes sense.

But I don't want it to be this "clever" as I'm using this xhtml property for sending email newsletters and truncating the domain from the image src would mean that the images won't be displayed properly.

Is there a way to disable this auto code cleanup function?

Oct 04, 2011 2:11

I had this same issue and could not find a concrete solution for this, I had to re-insert the domain using a find and replace before sending the email

Regex pattern = new Regex("(href|src)([^\"|']{1,3})([\"|']/)", RegexOptions.IgnoreCase);

emailBody = pattern.Replace(emailBody,string.Format("$1$2\"{0}/",ConfigurationManager.AppSettings["HostUrl"]));


Oct 05, 2011 16:42

I'm really trying to avoid that but if all else fail, that would be my last resort.

I'm still hoping that that there's a way to turn it off. Hopefully someone from EPiServer knows an answer.

Oct 06, 2011 1:54

Yeah, I have had this problem also. Why why why give an option to go to html mode and then mess up the code afterwards.

Iam also making newsletters, and it is hard as it is. Here is what I did, I had to make seperate propertys for the img's, see code. But Iam guessing you have figured that out. I think, if you really want the editor to be able to place the img's in an xhtml editor you can make the xhtmleditor work like in epi 5, Iam trying to find where you do that but cant find it neither under the settings for the property nor under admin>config, but I think it is possible (maybe in Epi 6 R2, I have R1 here at work).

Maybe you should take a look at this too:

<img src="<%= CurrentPage["TheProperty"] %>" />

<!-- *In the page type: TheProperty = URLtoIMAGE -->


Edited, Oct 12, 2011 11:22


There are a couple of possible places where url-rewriting could take place so to narrow down the problem I need some more context. The places are:

  • In Tiny MCE.
  • In permanent URL rewriting.
  • In HTML output rewriting.

Is the data stored as a property? If so, does the initial post to save the values have the correct data or has it been rewritten here already?

Oct 12, 2011 16:05

It's within the Tiny MCE (via a page Property).

So within the HTML Editor, when I have something written like:

<td colspan="3"><img src="" alt="" width="800" /></td>

And I click on update, and opened the HTML editor again, it will be rewritten as:

<td colspan="3"><img src="/Global/Promo/YDemail.jpg" alt="" width="800" /></td>


This will not work as we're using this for newsletters.

Oct 31, 2011 2:01

Hi again!

Here some test code that I did to rewrite URL:s to be absolute. I have just done basic testing so the code is provided as is:

var builder = new StringBuilder();

PropertyXhtmlString mainbody = CurrentPage.Property["mainbody"] as PropertyXhtmlString;

foreach (IStringFragment fragment in mainbody.Fragments)
    UrlFragment urlFragment = fragment as UrlFragment;
    if (urlFragment != null)
        var url = new Url(urlFragment.GetViewFormat());
        Uri uri = UriSupport.CreateAbsoluteUri(url);

Mailtest.Text = builder.ToString();


Oct 31, 2011 11:11

Hi Linus,

Thanks for the code, though code modification was really my last resort. I was hoping that there was a switch or config somewhere so that the URL won't get messed up. Looks like there's none.

Oct 31, 2011 22:46

I understand. Since the issue seems to be inside of Tiny MCE I'd suggest to post on the Tiny MCE forums to see if someone there can help you.

Nov 01, 2011 6:52
* 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.