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.
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:
Copy
Sitecore.Support.320556.dll
to thewebsite\bin
folder, the dll isn't on SDN yet, http://tareknasser.com/projects/sitecore/Sitecore.Support.320556.dllIn 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