add_image: Create an HTML fragment for an embedded image

Description Usage Arguments Value Examples

View source: R/add_image.R

Description

Add a local image inside the body of the email with this helper function.

Usage

1
2
3
4
5
6
7
add_image(
  file,
  alt = "",
  width = 520,
  align = c("center", "left", "right", "inline"),
  float = c("none", "left", "right")
)

Arguments

file

A path to an image file.

alt

Text description of image passed to the alt attribute inside of the image (<img>) tag for use when image loading is disabled and on screen readers. NULL default produces blank ("") alt text.

width

The width to be used for the image, in pixels.

align

The alignment to be used for the image. If not "inline", the image will appear in its own block, i.e. there will not be text to the left or right of it.

float

The float value to be used for the image. If not "none", text will flow around the image, and the align argument will be ignored.

Value

A character object with an HTML fragment that can be placed inside the message body wherever the image should appear.

Examples

 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
# Create an HTML fragment that
# contains an image
img_file_path <-
  system.file(
    "example_files",
    "test_image.png",
    package = "blastula"
  )

img_file_html <-
  add_image(file = img_file_path)

# Include the image in the email
# message body by simply referencing
# the `img_file_html` object
email <-
  compose_email(
    body = md(
      c(
"Hello,

Here is an image:\n",
img_file_html
      )
    )
  )

if (interactive()) email

rich-iannone/blastula documentation built on Oct. 17, 2020, 8:59 p.m.