Debian Codegraph @

man/base64_uri.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/base64.R
3 \name{base64_uri}
4 \alias{base64_uri}
5 \title{Generate the Data URI for a file}
6 \usage{
7 base64_uri(x, type = mime_type(x))
8 }
9 \arguments{
10 \item{x}{A file path.}
11
12 \item{type}{The MIME type of the file, e.g., \code{"image/png"} for a PNG image
13 file.}
14 }
15 \value{
16 A string of the form \verb{data:<media type>;base64,<data>}.
17 }
18 \description{
19 Encode the file in the base64 encoding, and add the media type. The data URI
20 can be used to embed data in HTML documents, e.g., in the \code{src} attribute of
21 the \verb{<img />} tag.
22 }
23 \examples{
24 logo = xfun:::R_logo()
25 img = xfun::html_tag("img", src = xfun::base64_uri(logo), alt = "R logo")
26 if (interactive()) xfun::html_view(img)
27 }