Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include_graphics should error if file doesn't exist #1717

Closed
hadley opened this issue May 30, 2019 · 6 comments
Closed

include_graphics should error if file doesn't exist #1717

hadley opened this issue May 30, 2019 · 6 comments

Comments

@hadley
Copy link
Contributor

hadley commented May 30, 2019

It would be useful if include_graphics() threw an error if the image did not exist. Otherwise it's easy to miss broken images.

knitr::include_graphics("sadf")
#> [1] "sadf"
#> attr(,"class")
#> [1] "knit_image_paths" "knit_asis"   
@yihui
Copy link
Owner

yihui commented May 31, 2019

The main reason I didn't do it because It can also include images from http resources if the output format is HTML.

If the document is compiled to PDF, you should discover that the image is missing from the LaTeX error log.

@hadley
Copy link
Contributor Author

hadley commented Jun 1, 2019

Only check if the path is not a url?

(But there's no hint in the documentation that you can use urls, so I doubt many people rely on this behaviour)

@yihui yihui closed this as completed in 1648923 Jan 16, 2020
@yihui
Copy link
Owner

yihui commented Jan 16, 2020

Done. Thanks!

@NMarkgraf
Copy link

This is not a good idea! - If your child documents are in a subfolder and your images are in an other subfolder this would lead to an error even in pdflatex would handle it correctly!

PLEASE use a default value for "error=..." which can be set to knitr to set it to FALSE or TRUE for a whole document! I have to replace several documents by hand ...

yihui added a commit that referenced this issue Feb 7, 2020
@yihui
Copy link
Owner

yihui commented Feb 7, 2020

@NMarkgraf I just provided an global option (6daea79). You could override the function, e.g.

include_graphics = function(...) {
  knitr::include_graphics(..., error = FALSE)
}

@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants