Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with ConvertTo-PnPPage Command and Image Resizing #1101

Open
tatsutanaka opened this issue Jan 8, 2025 · 0 comments
Open

Issue with ConvertTo-PnPPage Command and Image Resizing #1101

tatsutanaka opened this issue Jan 8, 2025 · 0 comments

Comments

@tatsutanaka
Copy link

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="&#123;&quot;serverProcessedContent&quot;&#58;&#123;&quot;htmlStrings&quot;&#58;&#123;&#125;,&quot;searchablePlainTexts&quot;&#58;&#123;&#125;,&quot;imageSources&quot;&#58;&#123;&#125;,&quot;links&quot;&#58;&#123;&#125;&#125;,&quot;dataVersion&quot;&#58;&quot;1.0&quot;,&quot;properties&quot;&#58;&#123;&quot;script&quot;&#58;&quot;&lt;img src='{ServerRelativeFileName}' alt='{AlternativeText}'&gt;&quot;,&quot;title&quot;&#58;&quot;{Title}&quot;,&quot;removePadding&quot;&#58;false,&quot;spPageContextInfo&quot;&#58;false&#125;&#125;"/> </Mapping> </Mappings> </WebPart>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant