Forum Discussion
AS911
Nov 14, 2019Copper Contributor
C# ClientContext - Removing Image from Page Banner on Modern Page - SP 2019
I am trying to create a ClientSidePage in C#. I have been able to make the page, but I can't figure out how to remove the image from the Page Banner. The option exists to remove the image and keep th...
VamshiGovindu
Nov 29, 2021Copper Contributor
$page = Get-PnPClientSidePage -Identity Home.aspx
$lwc = $page.PageListItem.FieldValues.LayoutWebpartsContent
$newLwc = $lwc -replace ""imageSourceType":4,"", ""imageSourceType":0,""
Set-PnPListItem -List "SitePages" -Id $page.PageId -Values @{"LayoutWebpartsContent" = $newLwc} -SystemUpdate
This code here should remove the image from the page. ImageSourceType = 4 is default, ImageSourceType = 0 is none, ImageSourceType = 2 is custom image.
$lwc = $page.PageListItem.FieldValues.LayoutWebpartsContent
$newLwc = $lwc -replace ""imageSourceType":4,"", ""imageSourceType":0,""
Set-PnPListItem -List "SitePages" -Id $page.PageId -Values @{"LayoutWebpartsContent" = $newLwc} -SystemUpdate
This code here should remove the image from the page. ImageSourceType = 4 is default, ImageSourceType = 0 is none, ImageSourceType = 2 is custom image.