add_imgur_image: Deploy a local image to Imgur and create an image tag

View source: R/add_imgur_image.R

add_imgur_imageR Documentation

Deploy a local image to Imgur and create an image tag

Description

Getting images into email message bodies (and expecting them to appear for the recipient) can be a harrowing experience. External images (i.e., available at public URLs) work exceedingly well and most email clients will faithfully display these images. With the imgur_image() function, we can take a local image file or a ggplot2 plot object and send it to the Imgur service, and finally receive an image (⁠<img>⁠) tag that can be directly inserted into an email message using compose_email().

Usage

add_imgur_image(
  image,
  client_id = NULL,
  alt = NULL,
  width = 520,
  align = c("center", "left", "right", "inline"),
  float = c("none", "left", "right")
)

Arguments

image

The path to the local image we would like to deploy to Imgur and for which we'd like an image tag.

client_id

The Imgur Client ID value.

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.

Details

To take advantage of this, we need to first have an account with Imgur and then obtain a Client-ID key for the Imgur API. This can be easily done by going to ⁠https://api.imgur.com/oauth2/addclient⁠ and registering an application. Be sure to select the OAuth 2 authorization type without a callback URL.

Value

An HTML fragment that can be placed inside the message body wherever the image should appear.


blastula documentation built on May 29, 2024, 4:22 a.m.