0

Quick question: I am working with R Shiny, and I am trying to embed pictures onto my app. Problem: when I load them, I can't seem to get the jpg or png on the screen. (I tried both file types.) Only a misloaded file icon appears. How do you get this fixed? Any help would be much appreciated.

I tried a variety of options, but here is the simplest code. I'm just trying to remove as many variables as possible. The skiing.png should be in my folder.


mainPanel(tags$img(src="skiing.png"),width=2) 


jeisenman19
  • 45
  • 1
  • 8

1 Answers1

0

Create a www sub-directory in your project directory and move the pictures there. There is no need to change the src path.

| project_dir/
  | app.R
  | www/
    |skiing.png

Please try this minimal example, with the image in the www directory. If this does not work, either your Shiny server is configured differently from the default or something else is wrong.

library(shiny)

ui <- fluidPage(
    sidebarLayout(
      sidebarPanel(), 
      mainPanel(tags$img(src="skiing.png"),width=2) 
  )
)

server <- function(input, output) { }
shinyApp(ui = ui, server = server)
Tom
  • 532
  • 3
  • 11
  • Hmmmm. I moved the picture in the www folder, but the image still won't render. It's a png screenshot. Any reason why this wouldn't work? – jeisenman19 Aug 18 '21 at 20:17