File: base64_uri.Rd

package info (click to toggle)
r-cran-xfun 0.37%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 792 kB
  • sloc: ansic: 242; sh: 22; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 869 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
25
26
27
28
29
30
31
% 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, type = mime::guess_type(x))
}
\arguments{
\item{x}{A file path.}

\item{type}{The MIME type of the file, e.g., \code{"image/png"} for a PNG
image file.}
}
\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.
}
\note{
By default, this function requires the \pkg{mime} package to determine
  the MIME type of the file.
}
\examples{
logo = xfun:::R_logo()
img = htmltools::img(src = xfun::base64_uri(logo), alt = "R logo")
if (interactive()) htmltools::browsable(img)
}