I'm using this link from the author of shinywidgets selectizeInput with image/icon to create a selectizeinput in shiny with images (already in the www folder), works well in local but images don't show on shiny server, I get no error, just images don“t show, only a blank square and the label.
Here is the code:
output$ui.menu.mosaicos <- renderUI({
#Could you use an action button, and set the style='background-img:path/to/img;'
#imagenes por cargar (mosaico - mosNOMBRE.png)
mosData <<- data.frame("mosaico" = list.files("www/", "mos[A-Z0-9]",
all.files = FALSE,
full.names = TRUE))%>%
mutate("nombres" = str_extract(mosaico,"[A-Z0-9].+\\.")%>%gsub("\\.", "", .),
"picker" = gsub("www/","", mosaico))
filling <- mosData%>%pivot_wider(-mosaico,names_from = nombres,values_from = picker)
selectizeInput(inputId = "pickMosaico",
label = "Mosaicos",
width = "200px",
choices = filling,
options = list(
render = I(
"{
option: function(item, escape) {
return '<div><img src=\"' + item.value + '\" width = 160 />' + escape(item.label) + '</div>'
}
}"))
)
})