2

Is it possible to create a new Image Rendition using PowerShell?

I have only been able to find .Net or XML solutions, such as...

using (SPSite site = new SPSite("http://spsite")) {
    ImageRenditionCollection imageRenditions = SiteImageRenditions.GetRenditions(site);

    ImageRendition rendition = new ImageRendition {
        Name = "New Rendition",
        Width = 295,
        Height = 295
    };

    imageRenditions.Add(rendition);
    imageRenditions.Update();
}

Can this be replicated in PowerShell?

2

You can use .NET assemblies in PowerShell, which makes it so powerful.

add-pssnapin microsoft.sharepoint.powershell
$site = Get-SPSite "http://spsite"
$imageRenditions =  [Microsoft.SharePoint.Publishing.SiteImageRenditions]::GetRenditions($site)

        $rendition = New-Object Microsoft.SharePoint.Publishing.ImageRendition
        $rendition.Name = "New Rendition"
        $rendition.Width = 295
        $rendition.Height = 295

$imageRenditions.Add($rendition)
$imageRenditions.Update()
$site.Dispose()
  • Do you know where the documentation is for this? I searched for a long time and couldn't find this. I'm out of the office this week so I'll have to give this a try when I'm back in next week. Thanks! – AverageMarcus Dec 10 '15 at 9:42
  • It's not a factor of documentation for this in powershell, just the know-how on how to translate .NET code into powershell. – Mike Dec 10 '15 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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