Issue related to src value in img tag - TinyMCE

Vote:
 

Optimizely 12.


We have a page with XhtmlString field, and whenever we try to insert an image, either from the Media files or directly adding it, the Src value does not show correctly after publishing the page 

for example, the src value would be something like this:
/EPiServer/CMS/Content/contentassets/1d2dd1505ebe4572b7e7d8d1683b4fb6/image-edit.jpg,,537?epieditmode=false

And the whole xhtmlString value would be:

<p>Direct upload:</p>
<p><img src="/EPiServer/CMS/Content/contentassets/1d2dd1505ebe4572b7e7d8d1683b4fb6/image-edit.jpg,,537?epieditmode=false" alt="Online-seminare" width="1600" height="900" /></p>

And of course, this breaks the images when viewing them live. 

Any advice?

#291903
Edited, Nov 18, 2022 16:41
Vote:
 

Hi,

In the first instance there are a couple of things I'd check.The first would be whether you're caching the page output or any part of the page which would result in the rendered XHtmlString being cached. If so, it could be that your cache is being built from the page when it's being viewed in edit/preview mode. That would result in all users seeing the image URLs as they would be in edit/preview mode rather than the public-facing friendly URLs.

The other would be how you're rendering the XhtmlString property on the page. If you're just outputting the property value to the page directly, for example like this:

@Html.Raw(Model.CurrentContent.MainBody)

the internal URLs in the property value won't be parsed and converted into their equivalent friendly URLs. Using PropertyFor() to render XhtmlStrings should ensure the URLs are correctly processed, for example:

@Html.PropertyFor(x => x.CurrentContent.MainBody)
#292019
Nov 21, 2022 11:11
Vote:
 

Hello Paul,

First: We are not using caching on any part of the page.

second: for the display, we are displaying it correctly

@Html.PropertyFor(x => x.CurrentContent.MainBody)

And this is how we add the field on the page 

         [CultureSpecific]
        [Display(GroupName = SystemTabNames.Content, Order = 310)]
        public virtual XhtmlString MainBody { get; set; }

 

#292021
Nov 21, 2022 12:03
* 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.