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

Disable Html Editor auto code cleanup

Vote:
 

I have a page with xhtml property and whenever I put an img src="www.currentsite.com/global/myimage.png" 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?

#54122
Oct 04, 2011 2:11
Vote:
 

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"]));

 

#54222
Oct 05, 2011 16:42
Vote:
 

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.

#54225
Oct 06, 2011 1:54
Vote:
 

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:
http://tedgustaf.com/en/blog/2011/4/publishing-plain-html-pages-in-episerver/

<img src="http://www.xyz.com<%= CurrentPage["TheProperty"] %>" />


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

    

#54369
Edited, Oct 12, 2011 11:22
Vote:
 

Hi!

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?

#54376
Oct 12, 2011 16:05
Vote:
 

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="http://masterpet.com/Global/Promo/YDemail.jpg" 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.

#54717
Oct 31, 2011 2:01
Vote:
 

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);
        builder.Append(uri.ToString());
    }
    else
    {
        builder.Append(fragment.GetViewFormat());
    }
}

Mailtest.Text = builder.ToString();

    

#54722
Oct 31, 2011 11:11
Vote:
 

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.

#54735
Oct 31, 2011 22:46
Vote:
 

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.

#54742
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.