README.md

shinygallery

Lifecycle Travis CI build
status AppVeyor build
status

Overview

This R package creates image gallery widgets with pagination to show images based on file or URL paths. shinygallery is built on top of jPages and Bootstrap.

If limits is set in options, only images within the specified interval are rendered. This allows, e.g., to display further images only after a page change; the loading speed is thus improved.

Installation

You can install the development version of shinygallery from GitHub:

# install.packages("devtools")
devtools::install_github("stefanieschneider/shinygallery")

Usage

if (interactive()) {
  library(shiny)
  library(shinygallery)

  get_uri <- function(file) {
    file_ext <- paste0("image/", tools::file_ext(file))
    base64enc::dataURI(file = file, mime = file_ext)
  }

  file_path <- system.file("extdata", package = "shinygallery")

  files <- list.files(file_path, full.names = TRUE)
  values <- rep(sapply(files, get_uri), 10)

  ui <- fluidPage(galleryOutput("gallery"))

  server <- function(input, output, session) {
    observe({
      req(input$gallery_click_id)
      req(input$gallery_click_value)

      print(input$gallery_click_id)
      print(input$gallery_click_value)
    })

    observeEvent(input$gallery_page_id, {
      print(input$gallery_page_id)
    })

    observeEvent(input$gallery_page_range, {
      print(input$gallery_page_range)
    })

    output$gallery <- renderGallery({
      gallery(values, height = 150, options = list(
        "detailsLabel" = "Details", "addLabel" = "Add",
        "titleLabel" = "Title", "subtitleLabel" = "Subtitle"
      ))
    })
  }

  shinyApp(ui, server)
}

Contributing

Please report issues, feature requests, and questions to the GitHub issue tracker. We have a Contributor Code of Conduct. By participating in shinygallery you agree to abide by its terms.



stefanieschneider/shinygallery documentation built on July 6, 2020, 7:46 p.m.