Tilde being added to src attribute of image tags in static html webpart

Gregg Duncan asked on October 21, 2015 21:26

We are in the process of upgrading from Kentico 7 to 8. We have static HTML webparts that have image tags in them. Viewing the src of the Static HTML webpart we can see that the img tags are like:

<img src="/path/to/img/in/content/tree/img_name" />

But viewing the html source that's rendered it looks like:

<img src="~/path/to/img/in/content/tree/img_name" />

Because the tilde is being added at the beginning of the path and we are using extensionless urls the tilde doesn't get processed by aspx. Therefor the images are not displaying.

Why is the tilde being added to these image tags when they don't appear in the source of the Static HTML webpart?

Correct Answer

Gregg Duncan answered on October 22, 2015 16:41

Thanks for the response. That was an old article but it did lead me to the fix. We had an issue with the output filter on the upgrade and support had told us to comment out the entry in the web config that matched #3 in the article. So after further investingation I found that changing that entry from:

<add name="XHtmlModule" type="CMS.CMSOutputFilter.OutputFilterModule, CMS.OutputFilter" />


<add name="XHtmlModule" type="CMS.OutputFilter.OutputFilterModule, CMS.OutputFilter" />

fixed the output filter issue we were seeing and changed the tilde (~) in my urls to a double slash (//). I was still getting 404 errors on my images but this was different anyway. Then I went to Configuration > Settings > System > Output Filter and set "Excluded XHTML Output Filter Urls" to '/' so it would not filter any Urls and this seems to have fixed it. I don't know yet if this will cause us any issues down the road but it looks good so far.

1 votesVote for this answer Unmark Correct answer

Recent Answers

Juraj Ondrus answered on October 22, 2015 08:33

Common issue is that the output filter is not set correctly or some lines are missing in the web.config file. Have you already seen this article?
The screen shot is from v7. But in v8 the settings are the same. No.2 may not apply for Kentico 8.1 and 8.2

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.