Sitecore versioned image not loading

前提是你 提交于 2019-12-06 03:40:24

There appears to be a bug with the <sc:image /> and FieldRenderer controls in that the generated URL doesn't have a language in the querystring.

You can try something like this:

<asp:Literal ID="image" runat="server"><img src="{0}" /></asp:Literal>

Sitecore.Resources.Media.MediaUrlOptions options = new Sitecore.Resources.Media.MediaUrlOptions
{
    Language = Sitecore.Context.Language
};
Sitecore.Data.Fields.ImageField imgField = (Sitecore.Data.Fields.ImageField)Sitecore.Context.Item.Fields["Image"];
string url = Sitecore.Resources.Media.MediaManager.GetMediaUrl(imgField.MediaItem, options);
image.Text = string.Format(image.Text, url);

Sitecore support confirmed that it is a bug and here's their temporary workaround:

  1. Copy Sitecore.Support.320556.dll to the website\bin folder, the dll isn't on SDN yet, http://tareknasser.com/projects/sitecore/Sitecore.Support.320556.dll

  2. In the web.config file find and comment out the following node:

<processor type="Sitecore.Pipelines.RenderField.GetImageFieldValue, Sitecore.Kernel"/>

and add the following one below right after the commented one:

<processor type="Sitecore.Support.Pipelines.RenderField.GetImageFieldValue, Sitecore.Support.320556"/>

That worked for me in both the publish site and the page editor.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!