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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With