I have a simple script that we're running, where a content editor has bulk uploaded media and they want to go back through and provide attribution to the images (caption, alt text, photo credit) and it works, but on save the image that was attached get detached and lost.

The image is stored in the DB not as a file. If we only display a few fields (not the media field) it works fine but the editor can't see the image they're working on. I've tested with different permissions and that isn't a problem, we're receiving the following error:

Error

6536 13:15:40 ERROR Could not run the 'getMediaStream' pipeline for '/sitecore/media library/PathToFile'. Original media data will be used.
Exception: System.ArgumentException
Message: Value of 'null' is not valid for 'stream'.
Source: System.Drawing
   at System.Drawing.Bitmap..ctor(Stream stream)
   at Sitecore.Resources.Media.SaveColorProfileProcessor.Process(GetMediaStreamPipelineArgs args)
   at (Object , Object[] )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
   at Sitecore.Resources.Media.Media.GetStreamFromPipeline(MediaOptions options, Boolean& canBeCached)

Script Sample

$location = get-location
$items = Get-ChildItem -recurse $location | Where-Object { $_.Fields["Alt"] -ne $null }

ForEach ($item In $items) {
  if([Sitecore.Resources.Media.MediaManager]::HasMediaContent($item) -And $item."Alt" -eq ''){
    Lock-Item -item $item
    Show-FieldEditor -item $item -Name "alt","caption","Photo Credit","-Media", "-Marketing asset", "-Asset 1", "-Asset 1", "-Asset 2", "-Asset 3", "-File Path"
    Unlock-Item -item $item
  }
}

Non-working Script Sample

$location = get-location
$items = Get-ChildItem -recurse $location | Where-Object { $_.Fields["Alt"] -ne $null }

ForEach ($item In $items) {
  if([Sitecore.Resources.Media.MediaManager]::HasMediaContent($item) -And $item."Alt" -eq ''){
    Lock-Item -item $item
    Show-FieldEditor -item $item -Name "*", "-Marketing asset", "-Asset 1", "-Asset 1", "-Asset 2", "-Asset 3", "-File Path"
    Unlock-Item -item $item
  }
}

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.