How to save images as base64 string
Hello,
we're saving the whole html-content/output of the RichtTextEditor as string in our sql database.
We want to add some Images to this content. We dont use a local filesystem (blob) for saving images.
Is there a way to convert the blob
<img src="blob:http://blazor.syncfusion.com/3ab56a6e-ec0d-490f-85a5-f0aeb0ad8879">to
<img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO 9TXL0Y4OHwAAAABJRU5ErkJggg==">
In this way, we can save the images together with the html content in our database as a string.
Is that possible? Can somebody tell me how?
I found this thread for mvc, is there a way to do that in blazor?
https://www.syncfusion.com/forums/143705/how-to-save-images-as-base64-string
Thanks,
Nils
|
<SfRichTextEditor @ref="rteObj">
<ChildContent>
...
<RichTextEditorImageSettings SaveFormat="SaveFormat.Base64"></RichTextEditorImageSettings>
</ChildContent>
</SfRichTextEditor> |
Sample: https://www.syncfusion.com/downloads/support/forum/167147/ze/RichTextEditor_Base641957681365
Please check the sample and let us know if the solutions help,
That worked for me, thanks!!
Is there support for multiple images in the same RichTextEditor?
I tried it based on the example you provided and it does not seem to support more than one image in the RichTextEditor.
let's see what the syncfusion team has to say about it :)
Hey Gunasekar,
i think u have to validating Frank's query, on my point its all fine :)
Hi Nils,
- By using the Insert Image popup on RichTextEditor Toolbar.
- Drag and drop from file explorer.
- Copy and paste into the RichTextEditor.
- Which way you are used to inserting the images into the RichTextEditor.
As I'd feared, there's some kind of limit on the size of images that can be inserted into the RichTextEditor when the save format is specified as Base64. Trying to insert an image beyond a certain size causes the upload bar to stop at a certain point. Is this a browser memory issue, or something to do with a limit on the component? How can the limit(s) be raised programmatically?
By default behavior, RichTextEditor supports uploading images up to 30000000 Bytes. If the image size exceeds this size, then the images will not upload properly.
- RichTextEditor code snippets, that you have used.
- Any runnable sample to reproduce the issue.
- Any video reference for issue reproducing case.
- The exact package version you are using.
You can check the image size using the BeforeUploadImage event. Set
args.cancel=true if you need to prevent the image uploading. Thanks,
Gunasekar, that would explain it. Is there no way to raise the limit then?
Incidentally, I had to hunt this topic down again - surprisingly I don't see an obvious to see to see which posts I've commented on, or a way to get email notifications of replies. Is there a way?
I should add that I noticed another problem. When inserting an image, using the Browse to upload a file causes a mysterious crash. No clear exceptions thrown. Dragging/dropping doesn't do that.
https://stackoverflow.com/a/11402374
- 13 Replies
- 5 Participants
-
NS Nils Steinle
- Jul 12, 2021 01:53 PM UTC
- Nov 3, 2021 01:57 PM UTC