Image: Base64 as src is broken
See original GitHub issueOS: MacOS 10.14
React-pdf version: 1.0.0-alpha.18
Description:
Base64 as Image
src
is broken and throws Couldn't fetch image: <string>
. isomorphic-fetch
, which used node-fetch
under the hood throws Error: only http(s) protocols are supported
.
I suspect this commit, that implemented isomorphic-fetch
: https://github.com/diegomura/react-pdf/commit/72d0454c0876c24386b7a37b53f39293ef3540d0, as it’s younger than #216, which seems to conclude that this should be working as expected and documented in the docs.
Suggested actions
- Somehow detect and handle base64 strings as
src
, asnode-fetch
simply does not support this. Maybe something likeBuffer.from(<string>, 'base64')
. - Properly output
node-fetch
errors for future debugging, instead of justCouldn't fetch image: <string>
. - Add a base64 test case in
image.test.js
.
Alternatively, remove the instructions from the documentation, if this functionality is unwanted.
How to replicate issue including code snippet (if applies): https://runkit.com/embed/uj7thrhoup3u
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (2 by maintainers)
Top Results From Across the Web
Javasscript: load image with base64 not working
It looks like the base64 encoding for your image is incorrect. This renders a broken image <img src="data:image/png;base64 ...
Read more >Issue with Lazy Load and base64 - WordPress.org
Image is not being displayed and when inspecting the source code I notice base64 encoding for my image source: src="data:image/gif;base64 ...
Read more >How to fix broken base64 image using image-webpack and ...
The problem I was experiencing and tyring to document here is, after installing image-webpack and file-loader and using <img src={require('logo.
Read more >Storing and displaying images with base64 | by Tung Nguyen
Commonly, to display images in HTML or CSS we have to indicate URLs located ... Passes a base64 encoded data directly into “src”...
Read more >How to Display Base64 Images in HTML - W3docs
The <img> tag has a src attribute and contains the Data URL of the image. A Data URL is composed of two parts,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi guys!
Make sure that you insert the Image in the correct way:
<Image source={ {uri: 'YOUR IMAGE'} }/>
Next check if your base64 size is not too large. - if the size is ok, it should work.
same for me. No image is rendered.