EVOLUTION-MANAGER
Edit File: imgur_upload.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Upload an image to imgur.com</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for imgur_upload {knitr}"><tr><td>imgur_upload {knitr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Upload an image to imgur.com</h2> <h3>Description</h3> <p>This function uses the <span class="pkg">httr</span> package to upload a image to <a href="https://imgur.com">https://imgur.com</a>, and parses the XML response to a list with <span class="pkg">xml2</span> which contains information about the image in the Imgur website. </p> <h3>Usage</h3> <pre> imgur_upload(file, key = "9f3460e67f308f6") </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>file</code></td> <td> <p>Path to the image file to be uploaded.</p> </td></tr> <tr valign="top"><td><code>key</code></td> <td> <p>Client ID for Imgur. By default, this uses a client ID registered by Yihui Xie.</p> </td></tr> </table> <h3>Details</h3> <p>When the output format from <code><a href="knit.html">knit</a>()</code> is HTML or Markdown, this function can be used to upload local image files to Imgur, e.g. set the package option <code>opts_knit$set(upload.fun = imgur_upload)</code>, so the output document is completely self-contained, i.e. it does not need external image files any more, and it is ready to be published online. </p> <h3>Value</h3> <p>A character string of the link to the image; this string carries an attribute named <code>XML</code> which is a list converted from the response XML file; see Imgur API in the references. </p> <h3>Note</h3> <p>Please register your own Imgur application to get your client ID; you can certainly use mine, but this ID is in the public domain so everyone has access to all images associated to it. </p> <h3>Author(s)</h3> <p>Yihui Xie, adapted from the <span class="pkg">imguR</span> package by Aaron Statham </p> <h3>References</h3> <p>Imgur API version 3: <a href="https://apidocs.imgur.com">https://apidocs.imgur.com</a>; a demo: <a href="https://yihui.org/knitr/demo/upload/">https://yihui.org/knitr/demo/upload/</a> </p> <h3>Examples</h3> <pre> ## Not run: f = tempfile(fileext = ".png") png(f) plot(rnorm(100), main = R.version.string) dev.off() res = imgur_upload(f) res # link to original URL of the image attr(res, "XML") # all information if (interactive()) browseURL(res) # to use your own key opts_knit$set(upload.fun = function(file) imgur_upload(file, key = "your imgur key")) ## End(Not run) </pre> <hr /><div style="text-align: center;">[Package <em>knitr</em> version 1.29 <a href="00Index.html">Index</a>]</div> </body></html>