Skip to content

Instantly share code, notes, and snippets.

Embed
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"];
$item.Editing.BeginEdit();
$imageField.MediaID = $image.ID;
$imageField.Src = [Sitecore.Resources.Media.MediaManager]::GetMediaUrl($image)
$imageField.MediaPath = $image.MediaPath;
$item.Editing.EndEdit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.