LongText field rendering image URL incorrectly

Brenden Kehren asked on August 1, 2014 01:44

I have a doc type that has a long text field with a Rich Text Editor as the control. The user goes to the form and adds content. They added an image from the content tree and when it is rendered, there is an additional forward slash ( / ) added to the url.

When I save the data the text editor displays the image and when I view the source I see /path/to/image.png but in the database the data stored is ~/path/to/image.png. When the data is rendered simply using <%# Eval("BodyText") %> the src of the image field is rendered as //path/to/image.png causing the image to throw a 404 error.

I'm using 8.0.16

Correct Answer

Yehuda Lando answered on August 2, 2014 02:18

I contacted support about this about a month ago. It appears the default value of the Excluded XHTML filter URLs should actually be "/" (look when you make a new site using the corporate template), but isn't getting set to this on the empty templates.

This is how the setting should be.

And actually, it should be good for speed since the filter doesn't have to operate on any page. The only downside is that you have to have valid XHTML.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Yehuda Lando answered on August 1, 2014 09:14

You have to disable the XHTML filter (using the "Excluded XHTML filter URLs" settings).

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on August 1, 2014 13:37

Thanks Yehuda

I attempted that prior to posting with no success. Also not a very good solution as the user can place images pretty much anywhere in the site so I'd have to exclude all URLs and filter all output which wouldn't be very good for site speed.

Any other suggestions?

0 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on August 1, 2014 16:31

Could you take the Eval("BodyText").ToString() then do a replace for the '~' character? Or maybe replace '//' with '/'?

<%# Eval("BodyText").ToString().Replace("//","/") %>

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on August 1, 2014 18:40

Thanks Josh

The string.replace isn't an option because the user is entering text in a WYSIWYG editor box so they could add links or other images to outside links. They all work fine, its the internal URL to an image that is not working.

0 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on August 1, 2014 19:07

I see...that complicates things...it seems like the image upload or whatever form control is used in the doc type may need to be customized where you can control the values stored.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on August 2, 2014 04:41 (last edited on August 2, 2014 04:41)

Thanks Yehuda! I knew there was something simple, I never paid attention to the Corp site as I don't use it as a starting template. Thanks again

0 votesVote for this answer Mark as a Correct answer

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