Image not showing R Shiny (displayed as broken)

Hi,

I am trying to add a logo to my dashboard-header with the following code:

title <- tags$a(href='https://google.com',
                tags$img(src='logo.png'))

header <- dashboardHeader( title = title, uiOutput("logoutbtn"), titleWidth = 400)

The following is displayed instead of my logo.
image

I have tried the following:

  • Named my file app.R
  • Saved the "logo.png"-file in a subfolder called www
  • Pressed the Run App-button
  • Looked through many topics in the rstudio-community and on stackoverflow.

Can anyone help me? Please let me know if I have shared to little of code or anything else.

Thanks!! :smile:

I was able to reproduce similar issue if i clicked the 'Run App' button, but if I use runApp() directly in the concole, the picture can be displayed as expected, not sure why though...

ps. my current working directory is the same as the file path of app.R

library(shiny)
library(shinydashboard)

title <- tags$a(href='https://google.com',
                tags$img(src='b.jpg', width='100px',height='100px')) # an image downloaded from web (b.jpg under www folder)
                

header <- dashboardHeader( title = title, uiOutput("logoutbtn"))

ui <- dashboardPage(header, dashboardSidebar(), dashboardBody())


server <- function(input, output, session) {

}

shinyApp(ui, server)

Thank you for replying @ifendo ! I tried running the runApp()-function directly in the console, but it still does not work for me. Otherwise my code seems to be exactly the same as yours.

Could it perhaps be some updates I need to do?

By the way: the link works just fine. It's just the image-display that is faulty.

By default, RStudio searches in the 'www' folder. Try creating such a folder and place your image file in there. Make sure you still use the same path without 'www' for the src.