Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R Shiny: include image in modalDialog

Tags:

r

shiny

I want to show an image in a modalDialog, but R does not render one.

The following code only shows a link to the Google logo, but not the Google logo itself:

Server.R:

observeEvent(input$button, {
    showModal(modalDialog(
      title = "Title",
      '<img>https://www.google.nl/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png</img>',
      easyClose = TRUE,
      footer = NULL
    ))
  })

UI.R

actionButton(inputId ="button", label = "Click me")
like image 826
Dendrobates Avatar asked Dec 21 '17 16:12

Dendrobates


1 Answers

      observeEvent(input$button, {
        showModal(modalDialog(
          title = "Title",
          HTML('<img src="http://www.google.nl/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png">'),
          easyClose = TRUE,
          footer = NULL
        ))

  })

There is an error in your html. Use the HTML(...) tag to specify html code and then specify the source in the <img> tag. The above code works for me.

like image 70
sempervent Avatar answered Oct 09 '22 09:10

sempervent