Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding local image with html to a Shiny app

Tags:

r

shiny

I'm trying to add an image, located at my computer, but it's not working. I create an test.html file and when I open it with my browser (firefox), it renders the image. But when I try to use the same code with Shiny, it doesn't work. Below is the code I'm trying:

#html Code
<!DOCTYPE html>

<html>
<head>
    <title>
    Corinthians
    </title>
</head>
<body>
           <p>
               Vai corinthians
        </p> 

      <img id="stats_logo" align="right" src="file:///H://lab/comunicacao/logo hyper/logo_hyp.jpg" />   

  </body>

</html>

## Shiny Code
headerPanel_2(
HTML(
'<div id="stats_header">
                    Relatório de Horas
                    <a href="http://hyperativa.com.br/" target="_blank">
                    <img id="stats_logo" align="right" alt="" src="file:///H://lab/comunicacao/logo hyper/logo_hyp.jpg" />
                    </a>
                    </div>'
), h3, "Relatório de Horas"
)

And here is the functionm, headerPanel_2. that I'm using:

headerPanel_2 <- function(title, h, windowTitle=title) {    
  tagList(
    tags$head(tags$title(windowTitle)),
   h(title)
  )
}

The critical thing in the code, I think, is the "src="file:///H://lab/comunicacao/logo hyper/logo_hyp.jpg". What's wrong with that? How do I say to shiny where is the file located on my computer?

like image 536
Manoel Galdino Avatar asked Oct 17 '13 19:10

Manoel Galdino


1 Answers

You have to create a www directory inside shour shiny app directory and put your image inside. Then you can display it directly with :

<img src="logo_hyp.jpg" />

Of course, this works for every type of file : javascript, CSS, etc.

like image 145
juba Avatar answered Sep 19 '22 03:09

juba