0

I am trying to use an image as the title instead of text, but all I get in the app is the img icon, not the actual image. Here is my code.

library(tidyverse)
library(leaflet)
library(htmltools) 
library(shiny)

ui <- fluidPage(

    # Application title
    titlePanel(img(src = "www/BBBLogo.png",
                   height = 40,
                   width = 60)),
    sidebarLayout(

I can't seem to find the issue. Thanks in advance.

7
  • If your image is in www subfolder of your app, just do src = "/BBBLogo.png"
    – HubertL
    Commented Nov 11, 2020 at 23:15
  • Does this answer your question? Embedding an image with shinymanager R
    – HubertL
    Commented Nov 11, 2020 at 23:25
  • That did not work unfortunately
    – dumjo
    Commented Nov 11, 2020 at 23:26
  • It works on my setup... double check file name / folder and upgrade shiny
    – HubertL
    Commented Nov 11, 2020 at 23:29
  • I tried the link, but that is not exactly what I am trying to do. I think I should just be able to use the img function. I don't think I need a variable though
    – dumjo
    Commented Nov 11, 2020 at 23:30

1 Answer 1

1

You need tags$img and remove www. Try this

ui <- fluidPage(
  
  # Application title
  titlePanel(tags$img(src = "BBBLogo.png",
                 height = 50,
                 width = 50)),
  )

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

shinyApp(ui = ui, server = server)
4
  • I don't think there is any difference between img()and tags$img()
    – HubertL
    Commented Nov 11, 2020 at 23:54
  • As long as the image is in the www folder it should work. It works for me. Perhaps you need tags$li(a(tags$img(...))).
    – YBS
    Commented Nov 11, 2020 at 23:55
  • @HubertL, you are correct in this case. However, when my company updated browsers recently, my app which was working fine for 10 months stopped working. After changing img to tags$img, I was able to make it work again.
    – YBS
    Commented Nov 12, 2020 at 0:01
  • Good to know, I thought it was the same function (although why would there be two identical function?)
    – HubertL
    Commented Nov 12, 2020 at 0:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.