Deploy a local image to Imgur and create an image tag
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()
.
add_imgur_image( image, client_id = NULL, alt = NULL, width = 520, align = c("center", "left", "right", "inline"), float = c("none", "left", "right") )
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 |
width |
The width to be used for the image, in pixels. |
align |
The alignment to be used for the image. If not |
float |
The float value to be used for the image. If not |
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.
An HTML fragment that can be placed inside the message body wherever the image should appear.
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.