-
Notifications
You must be signed in to change notification settings - Fork 306
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
Setting banner image fails when setting it on the ClientSidePage #1049
Comments
Ok, thanks we will have a look and see if we can figure out what might be happening. The API we use isn't "public" as such and subject to breaking changes - perhaps something happened with how this works. |
It looks like the API now requires a server relative URL of the image - though I am not sure why your first snippet didn't work. I tested using the below successfully: const page = await sp.web.addClientsidePage("BannerTest6", "My Title");
const file = await sp.web.getFileByServerRelativeUrl("/sites/dev/Shared Documents/file.png").select("ServerRelativeUrl")();
page.setBannerImage(file.ServerRelativeUrl);
await page.save(); This code then failed, showing that the image needs to be in the same site collection: // this web is /sites/dev
const page = await sp.web.addClientsidePage("BannerTest6", "My Title");
page.setBannerImage("/Documents/file.png");
await page.save(); We need to update the docs to indicate the image file needs to exist in the same site collection as the page. Does this match what you are seeing? |
Thank you for your response. Sadly I still have the same problem though. |
And I have an update: const w = Web('https://server.sharepoint.com/teams/sitename');
return w().then(() => {
// first add the page
return CreateClientsidePage(w, ensurePageName(pageData.Title.value), pageData.Title.value);
}); Then the setBannerImage failed all the time no matter what URL I passed. const page = await sp.web.addClientsidePage(
ensurePageName(pageData.Title.value),
pageData.Title.value,
);
page.setBannerImage('/teams/sitename/Shared Documents/analysis.jpg');
await page.save(); Though I needed to have the whole relative url '/teams/sitename/Shared Documents/analysis.jpg' to make it work. Otherwise the setBannerImage would fail and complain about server relative url must be in use |
Yes, you need to use the ServerRelativeUrl to set the banner image. I have updated the docs to reflect this. Sounds like we are good to close this now? |
Yes closed it is !! Thanx |
Thanks! |
This issue is locked for inactivity or age. If you have a related issue please open a new issue and reference this one. Closed issues are not tracked. |
Category
Version
Please specify what version of the library you are using: [ 2.0.2 ]
Please specify what version(s) of SharePoint you are targeting: [ SharePoint Online ]
Expected / Desired Behavior / Question
When using addBannerImage the code fails. If I remove the addBannerImage() then the page gets created and everything works as it should. The error message is what follows:

Observed Behavior
I am not 100% sure but it seems like, when stepping through the code, that it fails somewhere when it tries to add the image to the layoutparts on the page.
Steps to Reproduce
First I uploaded a file by code in a document library in a sub folder within the same site and passed in the url to the function.
Then I hard coded with an image from the internet.
It failed as well.
The text was updated successfully, but these errors were encountered: