Hi,
I'm using PNG images inside my vignettes, because it's too long to knit.
The vignettes are rendered correctly with images showing.
Problem
The articles on the website, built from the vignettes, are not showing any images.
Additional info
fig.path anywhere.pkgdown::build_site()resources_files: and the names of the images inside the YAML header: no successLink to the vignette html, and here the link to my package article for the same vignette.
Looking at the html files revealed that the absolute link, on my hard drive, is used, for reason beyond me.
The html vignette: ok
<p><img src="data:image/png;base64,iVBORw0KGgoAAAAN [... break ...] BAAAEEE" /> By default, the figure display the range of the data, to change this behavior and see the full range for the y axis:</p>
The articles: not ok
<p><img src="../../../../../Mobile%20Documents/com~apple~CloudDocs/r_packages/assigner/vignettes/assignment_thl_test1.png"> By default, the figure display the range of the data, to change this behavior and see the full range for the y axis:</p>
Is it a bug or something that I'm doing wrong ?
Thanks
Thierry
I suggest not using resource_files at all and instead include graphics using knitr::include_graphics in an Rmd chunk.
I tried, same results
Here is the results of devtools::session_info()
─ Session info ────────────────────────────────────────────────────────────────────────────────────────────
setting value
version R version 3.6.0 (2019-04-26)
os macOS Mojave 10.14.4
system x86_64, darwin15.6.0
ui RStudio
language (EN)
collate en_CA.UTF-8
ctype en_CA.UTF-8
tz America/Montreal
date 2019-05-15
─ Packages ────────────────────────────────────────────────────────────────────────────────────────────────
package * version date lib source
assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.0)
backports 1.1.4 2019-04-10 [1] CRAN (R 3.6.0)
callr 3.2.0 2019-03-15 [1] CRAN (R 3.6.0)
cli 1.1.0 2019-03-19 [1] CRAN (R 3.6.0)
crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.0)
desc 1.2.0 2018-05-01 [1] CRAN (R 3.6.0)
devtools 2.0.2 2019-04-08 [1] CRAN (R 3.6.0)
digest 0.6.18 2018-10-10 [1] CRAN (R 3.6.0)
fs 1.3.1 2019-05-06 [1] CRAN (R 3.6.0)
glue 1.3.1 2019-03-12 [1] CRAN (R 3.6.0)
magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.0)
memoise 1.1.0 2017-04-21 [1] CRAN (R 3.6.0)
packrat 0.5.0 2018-11-14 [1] CRAN (R 3.6.0)
pkgbuild 1.0.3 2019-03-20 [1] CRAN (R 3.6.0)
pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.6.0)
prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.6.0)
processx 3.3.1 2019-05-08 [1] CRAN (R 3.6.0)
ps 1.3.0 2018-12-21 [1] CRAN (R 3.6.0)
R6 2.4.0 2019-02-14 [1] CRAN (R 3.6.0)
Rcpp 1.0.1 2019-03-17 [1] CRAN (R 3.6.0)
remotes 2.0.4 2019-04-10 [1] CRAN (R 3.6.0)
rlang 0.3.4 2019-04-07 [1] CRAN (R 3.6.0)
rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.0)
rstudioapi 0.10 2019-03-19 [1] CRAN (R 3.6.0)
sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.0)
usethis 1.5.0 2019-04-07 [1] CRAN (R 3.6.0)
withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.0)
[1] /Library/Frameworks/R.framework/Versions/3.6/Resources/library
You can copy the approach I took for rvest: https://github.com/tidyverse/rvest/blob/master/vignettes/selectorgadget.Rmd. I'm pretty sure this predates knitr::include_graphics() and that should work too, but it seeing a successful example might help you figure out your problem.
doesn't work
If I'm having problems = others out there with same problems and potential solutions, will continue searching the web
That's the vignette that builds http://rvest.tidyverse.org/articles/selectorgadget.html, so it definitely does work.
When I delete the full path of for png in docs/articles/get_started.html to force pkgdown articles to use the png it just copied inside docs/articles/, everything works. The pngs are rendered correctly, exactly like the vignette in vignettes/get_started.html
And this works using any of these in my original vignette:
knitr::include_graphics("assignment_thl_test3.png"), <img src="assignment_thl_test3.png">embed_png solution in restSo my guess is something wrong with pkgdown when it does the copying of the vignette, generating the full local path of the png instead of the relative path in docs/articles
That's the vignette that builds http://rvest.tidyverse.org/articles/selectorgadget.html, so it definitely does work.
It's difficult to compare for a novice in pkgdown like me, because the rvest vignette you mention as an example, if I look at the GitHub associated to rvest: https://github.com/tidyverse/rvest, there's no docs/articles/ html file for this vignettes. Just the Rmd.
I'm not putting the full path in my Rmd so the questions:
1) why is it generated in the first place ?
2) Is there an option/argument in pkgdown that I can use to stop it from doing this ?
A few things I've observed:
/Users/thierry/Library/Mobile Documents/com~apple~CloudDocs/r_packages/assigner/vignettes/assignment_thl_test3.png:knitr produce a vignette with images.pkgdown ::build_sitepkgdown doesn't produce an article with images.docs/articles, just the html file.assignment_thl_test3.png:knitr produce a vignette with images, as above.pkgdown ::build_sitepkgdown doesn't produce an article with images.docs/articles.Inside render_rmarkdown, src full path is probably recycled during html creation.
Most helpful comment
A few things I've observed:
/Users/thierry/Library/Mobile Documents/com~apple~CloudDocs/r_packages/assigner/vignettes/assignment_thl_test3.png:knitrproduce a vignette with images.pkgdown ::build_sitepkgdowndoesn't produce an article with images.docs/articles, just thehtmlfile.assignment_thl_test3.png:knitrproduce a vignette with images, as above.pkgdown ::build_sitepkgdowndoesn't produce an article with images.docs/articles.Inside
render_rmarkdown,srcfull path is probably recycled during html creation.