How to upload an external image to Shiny

In my current project, I am trying to upload images shiny dashboardusing R. The code snippet looks like this:

dashboardBody(
          hr(),
          fluidRow(
            column(6,align="center",imageOutput("ginger"))
          )
        )
      )

      server <- function(input, output) { 
        output$ginger <- renderImage({
          return(list(
            src = "images/ginger.jpg",
            contentType = "image/jpeg",
            width = 300,
            height = 200,
            alt = "Face"
          ))
        }, deleteFile = FALSE)

Basically, it just displays the image on shiny dashboard. Here the image is stored on the local machine. Now I want to download an image from Google Drive or from the Internet. I am trying to download an image from my Google Drive and the URL https://drive.google.com/file/d/0By6SOdXnt-LFaDhpMlg3b3FiTEU/view .

I couldn’t figure out how to load images from a Google drive or webpage into shiny ones and how to add a title to the image too? Did I miss something?

+1
1

. barebones shiny , , Google .

library(shiny)

# Define UI with external image call
ui <- fluidPage(
  titlePanel("Look at the image below"),

  sidebarLayout(sidebarPanel(),

                mainPanel(htmlOutput("picture"))))

# Define server with information needed to hotlink image
server <- function(input, output) {
  output$picture <-
    renderText({
      c(
        '<img src="',
        "http://drive.google.com/uc?export=view&id=0By6SOdXnt-LFaDhpMlg3b3FiTEU",
        '">'
      )
    })
}

shinyApp(ui = ui, server = server)
+3

All Articles