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

how can add images in learnr #137

Closed
rajkumarManiRaja opened this issue Jan 17, 2018 · 11 comments
Closed

how can add images in learnr #137

rajkumarManiRaja opened this issue Jan 17, 2018 · 11 comments

Comments

@rajkumarManiRaja
Copy link

No description provided.

@mine-cetinkaya-rundel
Copy link
Collaborator

mine-cetinkaya-rundel commented Jan 17, 2018

You can use the knitr::include_graphics function in an R chunk. See the ex-data-filter example tutorial for sample usage.

@jjallaire
Copy link
Member

jjallaire commented Jan 17, 2018

You can also use a markdown image so long as it is located in the images directory, see https://rstudio.github.io/learnr/#External_Resources

![](images/my-image.png)

@bborgesr bborgesr closed this as completed Mar 9, 2018
@Wario84
Copy link

Wario84 commented May 10, 2021

I was wondering if there is a way to add an image through the function quiz(...). So as an argument.

@schloerke
Copy link
Collaborator

quiz(
	question("My Question",
		answer(
			htmltools::img(
				src = "https://pkgs.rstudio.com/gradethis/reference/figures/logo.png"
			), 
			correct = TRUE
		)
	)
)

Screen Shot 2021-05-10 at 11 52 14 AM

@ninahauserberlin
Copy link
Contributor

I used both options but for both the preview just shows me a generic picture icon (file is found, looks fine in rmarkdown but disappears isn preview). Any ideas why?

@gadenbuie
Copy link
Member

@NinaCorrelAid where is the image located and how are you adding it?

@ninahauserberlin
Copy link
Contributor

ninahauserberlin commented Sep 8, 2021

Hey there! Thanks for the quick reply!
I am saving the PNG locally inside the folder where my RMD is located. Executing here::here() gave me "/Users/ninahauser/rprojects/lernplattform", so I put the PNG there. However then I got a "File not found error". Hence, I had to put it inside of "/Users/ninahauser/rprojects/lernplattform/lernplattform". It is now found.
I then tried both options:
a) ![DataUseCase](DataUseCase.png) - does not do anything in rendered but gives a fine looking preview in RMD
b) knitr::include_graphics("DataUseCase.png") - just gives me nothing.
Any leads?

@gadenbuie
Copy link
Member

Please try storing the photo in a directory called images/ next to the tutorial and referencing it using a relative file path, i.e. either as ![](images/DataUseCase.png) or knitr::include_graphics("images/DataUseCase.png").

@grover4
Copy link

grover4 commented Sep 23, 2021

Hi, So I am trying to run the learnr tutorials from the dsbox package on Rstudio Workbench and we are seeing this error

Rendering tutorial in a temp folder since learnr does not have write permissions in the tutorial folder: /sw/ebpkgs/software/rgdal/1.4-8-foss-2020a-R-4.0.0/dsbox/tutorials/01-edibnb

and consequently there is a problem with the graphics file not being found. Any thoughts on whether the learnr package works differently on a server than say on my laptop (because this works just fine on my laptop). Rstudio Workbench is running version Rstudio ver 1.4.1717-3 and the version of R is 4.0.0.

Quitting from lines 36-37 (01-edibnb.Rmd)
Error in knitr::include_graphics("images/madeleine-kohler-90Qn643Pq9c-unsplash.jpg") :
Cannot find the file(s): "images/madeleine-kohler-90Qn643Pq9c-unsplash.jpg"
Calls: sourceWithProgress ... withCallingHandlers -> withVisible -> eval -> eval ->
Execution halted

@gato365
Copy link

gato365 commented Mar 13, 2022

Is there a way to store a logo on each page?

@lhami
Copy link

lhami commented Mar 20, 2024

Is it a learnr constraint or a shiny constraint that the folder has to be called "images", specifically? It would be nice to be able to specify something like, say, img/ as the folder for consistency with the rest of the codebase I'm working on and the sake of not having to duplicate images. Is there a way to set the folders that the knit tutorial has access to in the options?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests