3

I want to publish with the command

quarto::quarto_publish_site()

my book-website.

The book-website is already setup on quarto-pub. If I don't add any image as a web link, the website runs and can be uploaded.

Now I add any image as a weblink, this is a exemplary code

![](https://www.website.com/wp-content/uploads/sites/2/2022/04/picture.jpg)

When I render it locally, it works. When I launch the command to publish it

compilation failed- error Unable to load picture or PDF file 'https://www.website.com/wp-content/uploads/sites/2/2022/04/picture.jpg'.

The publishing process is interrupted after this error. This is exactly the same if I launch the command from Terminal.

Is this intended to prevent to publish on quarto-pub links from other websites? Or I can do something to avoid to download all these pics?

GiulioGCantone
  • 195
  • 1
  • 10
  • 1
    Works fine for me. Can you provide more info (software versions etc) or a reprex? – Martin C. Arnold Sep 04 '22 at 09:56
  • I can give you this insight: I am actually using the book format, not the website format. When I try to publish figure links with website format, it works. For the book format, it does not. Even on a fresh new project. I think it is related to xelatex – GiulioGCantone Sep 05 '22 at 00:10
  • @GiulioGCantone, edit your question with what you have said in comment. Your question and your comment doesn't match and makes your question confusing. Also its better to include the `quarto` and `Rstudio` version you are using. – shafee Sep 05 '22 at 03:35

1 Answers1

0

Including images via URL is not supposed to work for PDF output, which is not a Quarto issue but comes from how Pandoc translates !()[] to LaTeX.

Instead, you could automatically generate a local copy of the file (if not available) and then include the image in an R code chunk like this:

```{r, echo=FALSE, fig.cap='Kid', dpi=100}
if(!file.exists("kid.jpg")) {
  download.file(
    url = "https://edit.co.uk/uploads/2016/12/Image-1-Alternatives-to-stock-photography-Thinkstock.jpg",
    destfile = "kid.jpg", 
    mode = "auto") 
  }
knitr::include_graphics("kid.jpg")
```

(of course, including the image via !()["kid.jpg"] at different location will work too once the file exists locally.)

Martin C. Arnold
  • 9,483
  • 1
  • 14
  • 22
  • I think that the suggestion to run a download.file() is sufficient, I just wanted to avoid to manually download all the images I copypasted – GiulioGCantone Sep 05 '22 at 17:47