3

Currently, I have been using the following code to display the Upload Advance Dialog for media files:

$itemPath = Get-Item "master:\media library\Files"
Receive-File ($itemPath) -AdvancedDialog

The dialog is working fine and is returning undetermined as expected. Even though, is there any scripts that can be run to retrieved the list of media that have just been installed?

Note

  • Users can upload Zip files or single/multiple images at once.
  • It is a requirement to use the Advance Dialog as point 1 states that user should be able to upload Zip Files

UPDATE

The aim of this development is to use the Sitecore Powershell to upload media and then update each uploaded media Alt Text with a value.

Below are some ideas how I can achieve this:

  1. Loop in the container to retrieve each media item Id and store in a list and then after installation of the package, update each media item alt text where the ID is not present in the list.

  2. Install the media items in a temporary folder in the media library. Perform the alt text update. Then, move each media item to the respective destination.

  • Does the item have a created date that you can use? – Michael West Apr 4 '17 at 12:49
  • Yes it does have but I do not want to be based on date since it may happen that lots media have been uploaded in the morning and in 1 or 2 hours later, another batch in uploaded. The aim here is to update the alt text. So, it is no great to loop in all media items just to update some. I will be updating the question – Hishaam Namooya Apr 4 '17 at 12:52
0

I would suggest to run audit report + update alt text for media items

Workaround Solution:

  • Get the list of media items which do not have alt text.
  • Update Alt text with their item name or title.

Scripts to play with:

//Get list of media items
$items = Get-ChildItem -Path "master:\sitecore\media library\images" -Recurse | Where-Object { $_.Fields["Alt"] -ne $null }

//Update Alt text for media items
foreach($item in $items) 
{
    if($item."Alt" -eq '') {
       $item.BeginEdit()
       $item.Fields["Alt"].Value = $item.Name
       $item.EndEdit()
    }
}

note:

  • I still believe, we would require alt text for all the media items as part of SEO.
  • It would be a big task only for the first time but moving forward we might get media items which are recently installed/uploaded + with no alt text.

i have done similar task while performing automated migration for content + media items :)

  • Thanks for the reply but I cannot allow for scanning the whole container where the media items will be stored. The reason is because we will have loads of items – Hishaam Namooya Apr 4 '17 at 15:52
  • 2
    This requirement is not stated in your question. You can't reasonably expect people to invest time in coming up with an answer, only to have it rejected by unspoken requirements. I'm closing the question as unclear - feel free to update the question to have it reconsidered. – Mark Cassidy Oct 31 '17 at 19:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.