Command set extension base 64 icons not rendering
Category
- [ ] Question
- [ ] Typo
- [x] Bug
- [ ] Additional article idea
Expected or Desired Behavior
Command set extension icon defined in base 64 inside the extension manifest file should be rendered normally as showed in https://docs.microsoft.com/en-us/sharepoint/dev/spfx/extensions/basics/configure-extension-icon#use-a-base64-encoded-image.
Observed Behavior
The icon defined in base 64 is not rendered at all and it's the exact same behavior as for the base 64 defined icon for Web part already reported there: #1834. Therefore I am copying some part of this issue description as it is the same behavior and it must definitely come from the same source.
From #1834:
Looking at the URL generated for the icon, the img src attribute appears to be prefixed with https://localhost:4321/ before the base64 encoded image. In fact, removing the https://localhost:4321/ from the src attribute renders the icon as expected.
For example, if source is: src="https://localhost:4321/data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwM..."
Replacing it for: src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwM..." will solve the issue.
The same behaviour can be observed on the local workbench and the hosted workbench.
And the same behavior can be observed in production: after packaging and installing the sppkg file.
Steps to Reproduce
-
Create an SPFx Command Set extension
-
Follow the instructions of https://docs.microsoft.com/en-us/sharepoint/dev/spfx/extensions/basics/configure-extension-icon#use-a-base64-encoded-image] for setting the command set icon as a base 64 defined image
-
Run gulp serve after configuring your serve.json file (adding any sharepoint list or library link) or run gulp serve --nobrowser and navigate to your sharepoint list/library and add the debug link.
-
Check an item if necessary and make your command set visible
-
The command set icon will be blank
-
Using the developer tools, inspect the icon for your web part.
-
Find the <img class="ms-Image-image ..." element
-
The src attribute will be prefixed with https://localhost:4321
-
Remove the https://localhost:4321 (leaving everything after, and including, the "data:image"
-
The icon will show
Supporting something besides image/png would help. svg's are great as icons.
Still nothing new about this ?
@Zhephyr54 Take a look at how I implemented referencing .svg files as icons.
See https://github.com/Puzzlepart/spfx-solutions/blob/master/Pzl.Ext.PDFExport/src/extensions/pdfExport/PdfExportCommandSet.manifest.json and https://github.com/Puzzlepart/spfx-solutions/blob/master/Pzl.Ext.PDFExport/gulpfile.js
Any news on this issue. I am facing this issue for listview command set extension. Infact, I tried to deploy everything on Azure but still my icon for the extension does not render. We have taken approach for Base64 and also taking relative path, but still it failed.
Hello, we are running into the same issue as RajSaraiya - we have a list view command set and are having issues with the icon not rendering.
We're finding when we use an absolute URL to a PNG file it works from some client machines but not others. The base64 encoded method mentioned in the link below works locally with gulp serve but does not work in a packaged spfx app.
https://docs.microsoft.com/en-us/sharepoint/dev/spfx/extensions/basics/configure-extension-icon
In the cases where it doesn't render (both with the URL and the base64 encoded image) we see something like the following in the browser developer tools:
<img src="" class="ms-Image-image ms-Image-image--contain ms-Image-image--portrait is-notLoaded is-fadeIn is-error image-326">
This is fixed and it will be rolling out in the start of June. I am going to close this as it is tracked by #1834
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues