Images
Since 0.1.0-alpha.22The image tool opens a dialog with the image's source, from your device or the web, its size, and its description: the alternative text screen readers read in its place. The size keeps the image's proportions. An image that only decorates can be marked decorative, with an empty description.
The dialog opens on its own after an image is pasted or dropped, so every image gets a description. Clicking an image selects it, and the tool then changes or removes it.
To let people upload images, map an endpoint in your app and set ImageUploadUrl to it. The editor posts each chosen, pasted or dropped image there as multipart form data, in a field named file, with the form's antiforgery token. The endpoint stores it and answers with its URL, as text or as JSON { "url": "..." }; the editor puts that URL in the value. Check the file's type and size on the server too.
With no endpoint, AllowDataImages embeds images in the value as data: URLs instead, which needs no storage but makes the value as large as its images. MaxImageSize limits both (2 MB by default). PNG, JPEG, GIF, WebP and AVIF are taken; SVG never is, since it can carry script.
Adding an image
Choose the image tool, then Upload, or paste or drop an image into the text. Here images are embedded with AllowDataImages, so nothing is stored.
Static
Preview
Copper kettle
Hand-hammered copper with a brass handle. Add a photo above or below this line.
Code
@* A product page's description: add a photo with the image tool's Upload, or paste or drop one. *@
<RichTextEditor Grow @bind-Value="_description" Label="Product description" Rows="8" AllowDataImages MaxImageSize="1_000_000" />
{
private string? _description = "<h2>Copper kettle</h2><p>Hand-hammered copper with a brass handle. Add a photo above or below this line.</p>";
}