Images in reprex without using IMGUR?

When supporting colleagues within my organisation, I'd like to encourage them to provide a reproducible example (reprex) using the reprex package, however I'm aware that embedding images in reprex rendered code uses the IMGUR hosting facility. This is likely not a big deal for the majority of posting situations - when posting here or to Stack Overflow or Github - but I feel uneasy about uploading images with proprietary data to an external hosting service. Would reprex work with other sharing services e.g. Onedrive? Or could the images be (are they?) self-contained in the HTML?

1 Like

Interesting topic, another use case would be when people are connected through a firewall or proxy server that blocks traffic to IMGUR.

reprex is only setting by default a knitr option called upload.fun to the function in knitr knitr::imgur_upload()

See about upload.fun in https://yihui.org/knitr/options/#package-options

You can provide your own function if you want. knitr::imgur_upload is an example.
You can find another in example for flicker in this old script

You can create a function based on this example: it must take a file in input and return a url in output I guess.

setting this options in a reprex will apply to the reprex code. for example, as shown in ?reprex, you can add

#+ setup, include = FALSE
knitr::opts_knit$set(upload.fun = my_upload_fun)

in your reprex code to change the option. if my_upload_fun = identity for example, no file will be publish to imgur - can be useful for some reprex.

Hope it helps.

2 Likes

I think this is worthy of a feature request on Github, asking for more uploading options (including non) from the reprex() function itself.

There is already such discussion in reprex

3 Likes

Thanks for pointing me to that thread. I think that answers my question. Sorry I couldn't find that issue / discussion earlier.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.