My requirement is to customize Rich Text so that when an image is added to RTE, the image tag gets converted into a picture element example : Image tag


picture tag

so that responsive images in Sitecore rich text editor

How can we achieve this?

1 Answer 1


You can do that with some customizations. Follow these steps and try to update the OOTB logic.

Open the InsetImage Dialog XML using this path

wwwroot\<your-site-root>\sitecore\shell\Controls\Rich Text Editor\InsertImage\InsertImage.xml

You will see on this file that the code is written in Sitecore.Client DLL. Here is the reference.

<CodeBeside Type="Sitecore.Shell.Controls.RichTextEditor.InsertImage.InsertImageForm,Sitecore.Client"/>

When you extract the DLL and go to InsertImageForm class, you will find the code writtn on OnOK method like below.

MediaUrlBuilderOptions shellOptions = MediaUrlBuilderOptions.GetShellOptions();
shellOptions.Language = this.ContentLanguage;
string text = !string.IsNullOrEmpty(HttpContext.Current.Request.Form["AlternateText"]) ? HttpContext.Current.Request.Form["AlternateText"] : mediaItem.Alt;
Tag image = new Tag("img");
this.SetDimensions(mediaItem, shellOptions, image);
image.Add("Src", MediaManager.GetMediaUrl(mediaItem, shellOptions));
image.Add("Alt", StringUtil.EscapeQuote(text));
image.Add("_languageInserted", "true");
if (this.Mode == "webedit")
base.OnOK(sender, args);
SheerResponse.Eval("scClose(" + StringUtil.EscapeJavascriptString(image.ToString()) + ")");

You need to override this method and then update your new Class and DLL reference in the InsertImage.xml file.

And it should work.

Refer this article for similar kind of customization.


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.