Skip to contents

Take character vectors of alternative text, image link destinations, and optional titles and return single glue vector of valid markdown inline image links. This inline is rendered as the <img> HTML tag. Note that the expected arguments of md_image() are reversed from md_link()

Usage

md_image(url, alt = "", title = NULL, ..., .name = FALSE, wrap = FALSE)

Arguments

url

A character vector of link destination (URL) strings.

alt

A character vector of alternative text that can be used to refer to an image.

title

The optional title of the link.

...

A sequence of alt = "/url" named vector pairs. If any such pairs are provided, .name will be considered TRUE.

.name

logical; if TRUE, the pairs in ... will be used instead of any values supplied to x and url.

wrap

logical; if TRUE, the URL is wrapped in angle brackets (<url>), which is required when the destination contains spaces.

Value

A glue vector of collapsed alternative text and associated URLs.

Details

Syntax for images is like the syntax for links, with one difference. Instead of link text, we have an image description. The rules for this are the same as for link text, except that (a) an image description starts with ![ rather than [, and (b) an image description may contain links. An image description has inline elements as its contents. When an image is rendered to HTML, this is standardly used as the image’s alt attribute.

Examples

if (file.exists("man/figures/logo.png")) md_image("man/figures/logo.png")
md_image("http://hexb.in/hexagons/eff.png")
#> ![](http://hexb.in/hexagons/eff.png)
md_image(EFF = "http://hexb.in/hexagons/eff.png")
#> ![EFF](http://hexb.in/hexagons/eff.png)
md_image("http://hexb.in/hexagons/eff.png", "EFF Hex Sticker", "Logo")
#> ![EFF Hex Sticker](http://hexb.in/hexagons/eff.png "Logo")