Skip to contents

Creates an image carousel

Usage

pixcarousel(
  path,
  caption = NULL,
  caption_valign = "none",
  caption_halign = "left",
  link = TRUE,
  caption_lightbox = TRUE,
  gap = "0px",
  border_radius = "0px",
  shuffle = FALSE,
  fit = "cover",
  position = "center",
  carousel = list(),
  lightbox = list(),
  h = "400px",
  width = NULL,
  height = NULL,
  elementId = NULL
)

Arguments

path

A character vector of full paths to images.

caption

A character vector of captions for the images. If used, it must be equal to the length of path.

caption_valign

A character denoting position of the caption. Options are 'none', 'top', 'center' or 'bottom'.

caption_halign

A character denoting horizontal justification of the caption. Options are 'left', 'center' or 'right'.

A logical or character vector. What happens when you click on the thumbnail? TRUE opens up the lightbox, FALSE to disable the lightbox. A character vector of custom URLs equal to length of path.

caption_lightbox

A logical or character vector. TRUE shows caption in lightbox, FALSE disables caption in lightbox. A character vector of characters equal to length of path.

gap

A character denoting spacing between thumbnails in valid CSS units. Applied to left and right of each image.

border_radius

A character denoting corner radius of the carousel in valid CSS units.

shuffle

A logical indicating whether images are randomly shuffled.

fit

String. Passed to object-fit CSS property.

position

String. Passed to object-position CSS property.

A list of options to customize the carousel. See details.

lightbox

A list of options to customize the lightbox. See details.

h

A character denoting height of the image thumbnails in valid CSS units.

width

A character denoting width of the widget in valid CSS units.

height

A character denoting height of the widget in valid CSS units.

elementId

A character string denoting parent container ID.

Details

carousel options
The carousel can be customized by passing a list of options to the carousel parameter. Here is an example;

pixcarousel(
 paths,
 carousel = list(
  slidesToShow = 3,
  slidesToScroll = 2
 )
)

The available options for carousel can be found at https://github.com/NickPiscitelli/Glider.js or https://nickpiscitelli.github.io/Glider.js/.

lightbox options:
The lightbox can be customized by passing a list of options to the lightbox parameter. Here is an example;

pixcarousel(
 paths,
 lightbox = list(
   touchNavigation = FALSE,
   loop = TRUE
 )
)

The available options for glightbox can be found at https://github.com/biati-digital/glightbox?tab=readme-ov-file#lightbox-options.

Examples

library(pixture)
paths <- c(
 "https://images.pexels.com/photos/572897/pexels-photo-572897.jpeg",
 "https://images.pexels.com/photos/7604425/pexels-photo-7604425.jpeg",
 "https://images.pexels.com/photos/4666748/pexels-photo-4666748.jpeg",
 "https://images.pexels.com/photos/4932184/pexels-photo-4932184.jpeg",
 "https://images.pexels.com/photos/4210900/pexels-photo-4210900.jpeg",
 "https://images.pexels.com/photos/3126574/pexels-photo-3126574.jpeg",
 "https://images.pexels.com/photos/167699/pexels-photo-167699.jpeg",
 "https://images.pexels.com/photos/1376201/pexels-photo-1376201.jpeg"
)
pixcarousel(paths)
# local example if (FALSE) { # \dontrun{ library(pixture) paths <- list.files(path=system.file("extdata/images",package="pixture"),full.names=TRUE) pixcarousel(paths) } # }