base64_uri | R Documentation |
Encode the file in the base64 encoding, and add the media type. The data URI
can be used to embed data in HTML documents, e.g., in the src
attribute of
the <img />
tag.
base64_uri(x, type = mime::guess_type(x))
x |
A file path. |
type |
The MIME type of the file, e.g., |
A string of the form data:<media type>;base64,<data>
.
This function requires the mime package to determine the MIME type of the file except for a few common MIME types.
logo = xfun:::R_logo()
img = htmltools::img(src = xfun::base64_uri(logo), alt = "R logo")
if (interactive()) htmltools::browsable(img)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.