Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#item I want to set the field on
$item = get-item "master:/content/home"
#image I want to use
$image = new-object -TypeName "Sitecore.Data.Items.MediaItem" -ArgumentList (get-item "master:/media library/Showcase/cognifide_logo")
#field I want to set on $item
$imageField = [Sitecore.Data.Fields.ImageField]$item.Fields["image"];
$imageField.MediaID = $image.ID;
$imageField.Src = [Sitecore.Resources.Media.MediaManager]::GetMediaUrl($image)
$imageField.MediaPath = $image.MediaPath;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment