image: Convert path/url to HTML Image Tag

Description Usage Arguments Value Note Examples

Description

IM - Wrap a path/url to generate an HTML tag. Often markup code: ![](url) lacks flexibility with centering and sizing. IM enables conrol of centering via altering the sty/center commands and control of sizing via the numeric values supplied to height and width.

IM2 - A wrapper for IM that sets the base path to "assets/img/". This allows the users to just specify the image name that resides in one of the following directories: 1-"~/assets/img" or 2-"~/figure".

IW - Text wrapped images.

IMF - A wrapper for IM that attempts to find the image in expected image directories. Uses the first available image matching the image name. No path/url is specified. IMS stands for 'image locate'.

IM_MO - Creates an HTML image tag with mouseover grow/shrink properties. Only takes integer width/height values converted to px.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
IM(path = "clipboard", link = NULL, width = 540, height = IE(width,
  round(width/1.5)), sty = IE(width, width * 1.05, 480), center = TRUE,
  new_win = TRUE, copy2clip = interactive(), print = FALSE)

IM2(image = "clipboard", loc = 1, ...)

IW(path = "clipboard", link = NULL, side = "right", width = 540,
  height = IE(width, round(width/1.5)), new_win = TRUE, top = -15,
  right = 20, left = 20, bottom = 0, copy2clip = interactive(),
  print = FALSE)

IMF(image = "clipboard", ...)

IM_MO(path = "clipboard", link = NULL, width = 32, height = 32,
  width2 = width * 10, height2 = height * 10, sty = width * 1.05,
  center = FALSE, new_win = TRUE, copy2clip = interactive(),
  print = FALSE)

Arguments

path

A character vector url/path to the image. Default is to read from the clipboard. Note that Windows users do not have to reorient slashes in local paths if reading from the clipboard.

link

character vector url/path to hyperlink the image to.

width

The width of the image. If NULL the defualt image width is used.

height

The height of the image. If NULL the defualt image height is used.

sty

The width of the style (used for centering).

center

logical. If TRUE the image will be centered, if FALSE image will be left justified.

new_win

logical. If TRUE the link will open in a new window.

copy2clip

logical. If TRUE attempts to copy the output to the clipboard.

print

logical. If TRUE cat prints the output to the console. If FALSE returns to the console.

image

A character vector name of the image. Default is to read from the clipboard.

loc

The location of the image: 1-/assets/img and 2-/figure.

side

The side the image should appear on c("left", "right").

top

Space between top margin and top of text.

right

Space on the right margin.

left

Space on the left margin..

bottom

Space between bottom margin and bottom of text (0 is defualt).

width2

The width to grow to during mouseover.

height2

The height to grow to during mouseover.

...

Other arguments passed to IM.

Value

Returns a character vector of an HTML image tag that embeds an image.

Note

IM_MO Requires a link to the ‘js/reports.js’ in the document as well as the document itself. Usually this is done automatically upon the use of new_report/presentation. IM_MO only takes integer width/height values which are converted to px.

Examples

1
2
3
4
5
6
IM("http://cran.r-project.org/Rlogo.jpg", width= NULL, print=TRUE)
IM("https://dl.dropboxusercontent.com/u/61803503/packages/reports.PNG", print =TRUE)
IM("http://cran.r-project.org/Rlogo.jpg", NULL, print=TRUE, link = "http://cran.r-project.org")
cat(IW("http://www.talkstats.com/images/misc/logo.png", "http://www.talkstats.com/",
    width=140, height=75), rep("So much text! ", 100))
IM_MO("http://i.imgur.com/VClk4DS.png", print =TRUE)

trinker/reports documentation built on May 31, 2019, 9:51 p.m.