You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently using the ConvertTo-PnPPage command and have encountered an issue related to image resizing when converting from classic to modern pages.
Here are the specifics of the issue:
I have images inserted into a Content Editor Web Part on the classic page.
When the page is converted to a modern page, these images are automatically converted into Image Web Parts.
Although the images are displayed, their sizes are different from the original.
To address this, I modified the Web Part mapping XML file to convert all instances of the Content Editor Web Part to the Community Script Editor.
However, when images are inserted into the Content Editor, the Web Part Type is recognized as "SharePointPnP.Modernization.WikiImagePart" instead of "Microsoft.SharePoint.WebPartPages.ContentEditorWebPart".
I then updated the XML file to map WikiImagePart to the Community Script Editor as well.
Unfortunately, this results in the loss of the style attribute of the images, which causes the image sizes to change.
Is there a way to preserve the style attribute of images when converting WikiImagePart to the Community Script Editor, or any other solution to maintain the original image sizes?
Here is the relevant portion of the XML file where I mapped WikiImagePart: <!-- Fake wiki image web part, used to handle images embedded in wiki text --> <WebPart Type="SharePointPnP.Modernization.WikiImagePart" CrossSiteTransformationSupported="true"> <Properties> <!-- Functions are executed in web part property order using the order they're listed in the functions attribute. This implies that {serverRelativeFileName} as function output can be used in any function executed after the ReturnServerRelativePath function Note that ImageLookup returns a Dictionary<string,string> with a collection of output parameters. Although these output parameters are not named in the model you can still use them. Consult the function documentation to understand the output parameters. --> <Property Name="ImageUrl" Type="string" Functions="{ServerRelativeFileName} = ReturnCrossSiteRelativePath({ImageUrl});ImageLookup({ServerRelativeFileName});{FileName} = ReturnFileName({ImageUrl})"/> <Property Name="AlternativeText" Type="string"/> <Property Name="Anchor" Type="string" Functions="ImageAnchorUrlRewrite({Anchor},{ImageUrl},{ServerRelativeFileName})"/> </Properties> <Mappings> <Mapping Default="true" Name="default"> <!-- Let's replace the images embedded in the wiki text with the CommunityScriptEditor web part --> <ClientSideWebPart Type="Custom" ControlId="3a328f0a-99c4-4b28-95ab-fe0847f657a3" Order="10" JsonControlData="{"serverProcessedContent":{"htmlStrings":{},"searchablePlainTexts":{},"imageSources":{},"links":{}},"dataVersion":"1.0","properties":{"script":"<img src='{ServerRelativeFileName}' alt='{AlternativeText}'>","title":"{Title}","removePadding":false,"spPageContextInfo":false}}"/> </Mapping> </Mappings> </WebPart>
The text was updated successfully, but these errors were encountered:
I am currently using the ConvertTo-PnPPage command and have encountered an issue related to image resizing when converting from classic to modern pages.
Here are the specifics of the issue:
Is there a way to preserve the style attribute of images when converting WikiImagePart to the Community Script Editor, or any other solution to maintain the original image sizes?
Here is the relevant portion of the XML file where I mapped WikiImagePart:
<!-- Fake wiki image web part, used to handle images embedded in wiki text --> <WebPart Type="SharePointPnP.Modernization.WikiImagePart" CrossSiteTransformationSupported="true"> <Properties> <!-- Functions are executed in web part property order using the order they're listed in the functions attribute. This implies that {serverRelativeFileName} as function output can be used in any function executed after the ReturnServerRelativePath function Note that ImageLookup returns a Dictionary<string,string> with a collection of output parameters. Although these output parameters are not named in the model you can still use them. Consult the function documentation to understand the output parameters. --> <Property Name="ImageUrl" Type="string" Functions="{ServerRelativeFileName} = ReturnCrossSiteRelativePath({ImageUrl});ImageLookup({ServerRelativeFileName});{FileName} = ReturnFileName({ImageUrl})"/> <Property Name="AlternativeText" Type="string"/> <Property Name="Anchor" Type="string" Functions="ImageAnchorUrlRewrite({Anchor},{ImageUrl},{ServerRelativeFileName})"/> </Properties> <Mappings> <Mapping Default="true" Name="default"> <!-- Let's replace the images embedded in the wiki text with the CommunityScriptEditor web part --> <ClientSideWebPart Type="Custom" ControlId="3a328f0a-99c4-4b28-95ab-fe0847f657a3" Order="10" JsonControlData="{"serverProcessedContent":{"htmlStrings":{},"searchablePlainTexts":{},"imageSources":{},"links":{}},"dataVersion":"1.0","properties":{"script":"<img src='{ServerRelativeFileName}' alt='{AlternativeText}'>","title":"{Title}","removePadding":false,"spPageContextInfo":false}}"/> </Mapping> </Mappings> </WebPart>
The text was updated successfully, but these errors were encountered: