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.

1 Response to Replacing mediaitems in Sitecore

  1. Pingback: Which of my old Sitecore posts are still valid in Sitecore 9? | Brian Pedersen's Sitecore and .NET Blog

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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.