sds_image_from_file: Embed Images Directly in HTML Document

View source: R/sds_image_from_file.R

sds_image_from_fileR Documentation

Embed Images Directly in HTML Document

Description

In HTML mode, knitr include_graphics() will generate a <img src= > tag to include an image file. To do this, the image file needs to be in a place where it is available for display when the HTML is rendered in a browser. For images in packages, this is not going to work.

Usage

sds_image_from_file(
  filepath,
  width = "80%",
  height = NULL,
  tex_width = width,
  format = ifelse(knitr::is_html_output(), "html", "latex"),
  more_tags = ""
)

Arguments

filepath

character string with path to the image file. The image file must be PNG or JPEG or something that works in HTML

width

An optional character string specifying the width in some valid HTML format, e.g. "50%"`` or "10px"'. Ignored in latex output.

height

Like width

tex_width

Optional character string giving width of image in a latex-suitable format, e.g. "100pt". When tex_width is defined, it has priority over width.

more_tags

An optional character string containing more text to be inserted into the <img> tag.

Format

Character string specifying output format from knitr processing. This will be set automatically when run within knitr.

Value

A character string containing an <img> tag with a b64 encoded image as the value of the src= field.

Examples

## Not run: 
# in an inline knitr chunk ...
sds_image_from_file("myimage.png")

## End(Not run)

dtkaplan/SDSdata documentation built on June 28, 2022, 8:09 a.m.