富文本字段编辑器中图像 src 属性中的 Sitecore 参考媒体库图像

Sitecore Reference media library image in an image's src attribute inside Rich Text field editor

我正在使用 sitecore 8.1,我有一个模板包含 "Rich Text" 类型的字段,我正在基于此模板创建项目并在该字段中存储 HTML 内容。所有 HTML 标签和一切正常,除了 HTML 内容中包含的图像(在 src 属性中),我已经尝试了以下所有方案但都失败了:

Note: All the following scenarios' results are showing the image properly inside the Rich Text Editor inside sitecore CMS but when trying to render the HTML in a mobile web view or any browser, the HTML looks properly but just images are empty. And there is only one way I've tried and it worked but doesn't meet my requirements which is by mention an external URL inside src like:

src="http://i.telegraph.co.uk/multimedia/archive/03589/Wellcome_Image_Awa_3589699k.jpg"

场景:

我更愿意使用 Sitecore 的媒体库来避免最后一种情况

不使用ashx扩展名,可以直接在富文本中使用图片的sitecore路径,如下图:

src="~/media/path/to/image/logo.jpg"

然后按照您上面提供的,从富文本中检索值,如下所示:

var richTextValue = item.Fields["Body"].Value;

谢谢