r Shiny:来自www的renderImage

时间:2016-04-13 13:48:00

标签: r shiny

尝试从互联网上渲染图片时,

renderImage无法正常工作。当图像在本地计算机上时,它可以工作。

  output$myImage <- renderImage({
    pfad <- "https://www.rstudio.com/wp-content/uploads/2014/03/blue-125.png"
    list(src = pfad,
         contentType = 'image/png',
         width = 400,
         height = 300,
         alt = "This is alternate text")
  }, deleteFile = F)


imageOutput("myImage")

1 个答案:

答案 0 :(得分:4)

您可以直接在ui或反应式上下文中使用tags$img

library("shiny")
ui <- fluidPage(
  fluidRow(
    column(
      6,
      tags$img(src = "https://www.rstudio.com/wp-content/uploads/2014/03/blue-125.png")
    ),
    column(
      6,
      uiOutput(outputId = "image")
    )
  )
)
server <- function(input, output) {
  output$image <- renderUI({
    tags$img(src = "https://www.rstudio.com/wp-content/uploads/2014/03/blue-125.png")
  })
}
shinyApp(ui = ui, server = server)