12.1 Bookdown Insert Image From URL
20210316
With multiple output targets, such as html and latex, we need a little care in ensuring each is supported. A common use case is to include an image from a specific URL with the html document. This is accomplished with markdown:

However for latex output the path is expected to be a local path to the image file. Instead we can utilise knitr::include_url():
if (knitr::is_html_output())
{
knitr::include_graphics("https://bit.ly/3lfNVG6")
} else {
knitr::include_url("https://bit.ly/3lfNVG6")
}
This might be included in an R code block that begins with:
{r echo=FALSE, fig.align="left", out.width="50%"}
An image can be resized:
