0

I've got a Rich Text Field and using glass mapper to render the body field

[SitecoreField(I_HasPageContentConstants.BodyFieldName, Setting = SitecoreFieldSettings.RichTextRaw)]
string Body  {get; set;}

@Html.Glass().Editable(x => x.Body)

my rich text content is rendered however media that is embedded in the RTE content renders out with the .ashx extension.

Glassmapper doesn't seem to be using the Media.RequestExtension setting.

<!--  MEDIA - REQUEST EXTENSION
        The extension to use in media request URLs.
        If the value is not set, the Extension field of the individual media items will be used (ie. JPG, GIF, etc.)
        Default value: "ashx"
  -->
<setting name="Media.RequestExtension" value="" />

I've tested rendering the field using Sitecore field rendering such as (below) and it works as expected.

@Html.Sitecore().Field("Body")

Is there a way I can get glass mapper to render RTE content and correctly render linked media with the Media.RequestExtension setting?

using the following glass package

<package id="Glass.Mapper.Sc.101" version="5.8.180" targetFramework="net48" />
1
  • 1
    Could you please try removing SitecoreFieldSettings.RichTextRaw ? Commented Aug 1, 2022 at 9:28

1 Answer 1

1

If you will specify SitecoreFieldSettings.RichTextRaw, Sitecore will only call Render Field pipeline when rendering this field in edit mode. This means links within the field are not processed and converted when rendered on the front end. Links will have the default .ashx extension. To have links within your Rich Text fields to render with user-friendly URLs (not with the .ashx extension), the setting Media.RequestExtension needs to be blank (which you already not have) and your Rich Text fields must not have SitecoreFieldSettings.RichTextRaw.

[SitecoreField(I_HasPageContentConstants.BodyFieldName)]
string Body  {get; set;}

config setting -

<!--  MEDIA - REQUEST EXTENSION
    The extension to use in media request URLs.
    If the value is not set, the Extension field of the individual media items will be used (ie. JPG, GIF, etc.)
    Default value: "ashx"
 -->
<setting name="Media.RequestExtension" value="" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.