File: base64_uri.Rd

package info (click to toggle)
r-cran-xfun 0.20-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 680 kB
  • sloc: ansic: 242; sh: 22; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 644 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/base64.R
\name{base64_uri}
\alias{base64_uri}
\title{Generate the Data URI for a file}
\usage{
base64_uri(x)
}
\arguments{
\item{x}{A file path.}
}
\value{
A string of the form \verb{data:<media type>;base64,<data>}.
}
\description{
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 \code{src}
attribute of the \verb{<img />} tag.
}
\examples{
logo = xfun:::R_logo()
img = htmltools::img(src = xfun::base64_uri(logo), alt = "R logo")
if (interactive()) htmltools::browsable(img)
}