Sitecore versioned image not loading

爷,独闯天下 提交于 2019-12-12 09:48:24

问题


I'm running Sitecore 6.5 and have a data template that has an image field and an item that's based on that template. The site had two languages.

If I use a versioned image (one item in the media library with En and Fr versions) in the En and Fr versions of the item then publish the site and switch the language in the site using query string, sc_lang=en or fr, everything changes in the page except for the image.

But if I use two different images (two items in the media library) then the correct image loads when switching between languages.

Any idea to why this happens?

Thanks T

Update

I tried using the shared option and that didn't work. I also noticed that if I just add the query parameter and hit enter, the page changes to correct language but the image doesn't until I hit the refresh button. It seems a caching issue but why does it happen only with versioned images.


回答1:


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);



回答2:


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.



来源:https://stackoverflow.com/questions/8422013/sitecore-versioned-image-not-loading

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