Try our conversational search powered by Generative AI!

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
Praful Jangid - Dec 19, 2022 13:06
Giving you upvote for nicely explained to debug the issue.
Thanks Paul.
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
Vote:
 

Do you have any Save och Publishing event that may alter the value of MainBody that could be the cause of this?

#293137
Dec 14, 2022 8:50
Vote:
 

Issue fixed.
the reason behind that behavior was that the Host Name in the Admin - Config section was referring to another environment (Due to database copy).
and after fixing that, the images and videos are loaded correctly and the img src value are correct

#293139
Dec 14, 2022 9:58
Anawilliam - Dec 29, 2022 2:02
That is good, thank you for sharing how you fix it, I was looking for a solution to this problem
* 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.