sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

Command set extension base 64 icons not rendering

Open Zhephyr54 opened this issue 8 years ago • 7 comments

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

  1. Create an SPFx Command Set extension

  2. 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

  3. 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.

  4. Check an item if necessary and make your command set visible

  5. The command set icon will be blank

  6. Using the developer tools, inspect the icon for your web part.

  7. Find the <img class="ms-Image-image ..." element

  8. The src attribute will be prefixed with https://localhost:4321

  9. Remove the https://localhost:4321 (leaving everything after, and including, the "data:image"

  10. The icon will show

Zhephyr54 avatar May 25 '18 09:05 Zhephyr54

Supporting something besides image/png would help. svg's are great as icons.

wobba avatar Jul 31 '18 12:07 wobba

Still nothing new about this ?

Zhephyr54 avatar Dec 19 '18 21:12 Zhephyr54

@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

wobba avatar Dec 20 '18 09:12 wobba

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.

RajSaraiya avatar Apr 03 '19 13:04 RajSaraiya

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">

csgkeith avatar Apr 17 '19 07:04 csgkeith

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

GrahamMcMynn avatar May 09 '19 18:05 GrahamMcMynn

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

msft-github-bot avatar Jan 27 '20 18:01 msft-github-bot