AI OnAI Off
Why are you creating a writable clone of the image in an InitializableModule? Just curious...
We need to be able to populate the culture specific properties of the media item with language specific, translated values.
Without creating a writable clone, were unable to do so - the object properties are readonly.
Might want to do that on OnPublished event instead to avoid performance problems? Might also solve your bug...
Unfortunately that's not possible - we need to be able to present an editor with the correctly translated property values on load, in the all property view in EPiServer.
We store the translated property values in DDS, just like the article link described in my original post.
We currently have an issue in our project concerning hooking into the LoadedContent event for Images.
We have incorporated a solution described in the following blog post by Patrick Van Kleef, in order to allow images to be translatable in EPiServer.
http://www.patrickvankleef.com/2014/06/16/use-culture-specific-mediadata-properties/
For the most part the solution works, and the property values are overwritten when viewing the image in EpiServer, and rendering it via the website.
One issue we have experienced though, is if an editor wants to upload an update to the image (with the same name as the original), the update doesn't take place - the thumbnail and image are not updated with the new image.
If I look at the blobs in app_data, I can see that the new version of the image I have attempted to upload, has been written to the file system, but the thumbnail has not been created, and the image itself still points to the previous BinaryData and Thumbnail blob locations.
After debugging the code, I noticed that the issue doesn't arise from any of the translate custom code, but as soon as we create a clone of the image object. Can anyone provide a reason as to why this may happen?
Below is a cutdown version of the initialization module we use to attach to the LoadedContent event for images.
///
/// Media initialization
///
[InitializableModule]
public class MediaInitialization : IInitializableModule
{
private static readonly ILogger Logger = LogManager.GetLogger();
///
/// Initialize
///
///
public void Initialize(EPiServer.Framework.Initialization.InitializationEngine context)
{
DataFactory.Instance.LoadedContent += Instance_LoadedContent;
}
public void Uninitialize(EPiServer.Framework.Initialization.InitializationEngine context)
{
}
#region Event Handlers
///
/// Loaded content event handler
///
///
///
private void Instance_LoadedContent(object sender, ContentEventArgs e)
{
if (e.Content is IMediaTranslation)
{
var original = e.Content;
var clone = (IContent)((ImageData)original).CreateWritableClone();
e.Content = clone;
}
}
#endregion
}
I have replicated the issue in the Alloys project.
Any help or advice would be much appreciated!
Thanks,
Paul