Question

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?

Was it helpful?

Solution

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()
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top