Replacing mediaitems in Sitecore

This tip is from one of my colleagues Frederik Örnfelt who read my post about Adding a file to the Sitecore Media Library. But instead of adding files, he simply wanted to replace one item with another. Replacing media items is also done using the Sitecore MediaManager and a little stream magic:

Media sourceMedia = MediaManager.GetMedia(_sourceMediaItem);
Media targetMedia = MediaManager.GetMedia(mediaItem);

Thanks Frederik. And happy easter.

About briancaos

Developer at Pentia A/S since 2003. Have developed Web Applications using Sitecore Since Sitecore 4.1.
This entry was posted in .net, c#, General .NET, Sitecore 6 and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s