if (FALSE) {
if (interactive()) {
library(shiny)
library(htmltools)
library(r2resize)
# Example 1: Simple image gallery with a single container ID
shinyApp(
ui = fluidPage(
h3("Single Image Gallery Example"),
shinyExpandImage(c("gallery1")), # Initialize viewer for \'gallery1\'
tags$div(
id = "gallery1",
tags$a(
href = "https://r2resize.obi.obianom.com/m/1b.jpg",
tags$img(src = "https://r2resize.obi.obianom.com/m/1b.jpg",
alt = "Sample Image 1",
style = "width: 150px; height: 100px; object-fit: cover;")
),
tags$a(
href = "https://r2resize.obi.obianom.com/m/1.jpg",
tags$img(src = "https://r2resize.obi.obianom.com/m/1.jpg",
alt = "Sample Image 2",
style = "width: 150px; height: 100px; object-fit: cover;")
),
tags$a(
href = "https://r2resize.obi.obianom.com/m/1c.jpg",
tags$img(src = "https://r2resize.obi.obianom.com/m/1c.jpg",
alt = "Sample Image 3",
style = "width: 150px; height: 100px; object-fit: cover;")
)
)
),
server = function(input, output) {}
)
# Example 2: Multiple image galleries on the same page
shinyApp(
ui = fluidPage(
h3("Multiple Image Galleries Example"),
shinyExpandImage(c("myGalleryA", "myGalleryB")), # Initialize for both galleries
h4("Gallery A: Nature"),
tags$div(
id = "myGalleryA",
tags$a(
href = "https://r2resize.obi.obianom.com/m/1b.jpg",
tags$img(src = "https://r2resize.obi.obianom.com/m/1b.jpg",
alt = "Nature Image 1",
style = "width: 120px; height: 80px; object-fit: cover;")
),
tags$a(
href = "https://r2resize.obi.obianom.com/m/1c.jpg",
tags$img(src = "https://r2resize.obi.obianom.com/m/1c.jpg",
alt = "Nature Image 2",
style = "width: 120px; height: 80px; object-fit: cover;")
)
),
h4("Gallery B: Abstract"),
tags$div(
id = "myGalleryB",
tags$a(
href = "https://r2resize.obi.obianom.com/m/1.jpg",
tags$img(src = "https://r2resize.obi.obianom.com/m/1.jpg",
alt = "Abstract Image 1",
style = "width: 100px; height: 100px; object-fit: cover;")
),
tags$a(
href = "https://r2resize.obi.obianom.com/m/2.jpg",
tags$img(src = "https://r2resize.obi.obianom.com/m/2.jpg",
alt = "Abstract Image 2",
style = "width: 100px; height: 100px; object-fit: cover;")
)
)
),
server = function(input, output) {}
)
}
}
Run the code above in your browser using DataLab