Shiny: HTML image hyperlink

Hi,

I have been able to display an image in a shiny application with the code below with the image in a www folder:

headerPanel(
list(tags$head(tags$style()),
HTML('<img src="image.png", height="100px",width="20px style="float:left"/>'))),

Please does anybody know how to add a hyperlink to this code, to enable a user to click the image and hyperlink it to another site? Thanks in advance.

in HTML, it should be like this

 <a href="https://newsite.com"><img src="image.png" title="Example Image Link" width="600" height="400" /></a> 

that could be written as is or using htmltools shiny helper

tags$a(
  href="https://newsite.com", 
  tags$img(src="image.png", 
           title="Example Image Link", 
           width="600",
           height="400")
)

I think you can adapt to your example and use case.

Hope it helps

2 Likes

Hi,

Thank you very much for the quick response. Your solution worked perfectly well for me. Thanks.

Glad it works!

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.