Skip to contents

This is a demo on customizing the lightbox. pixture uses GLightbox for lightbox functionality. You can pass options to the lightbox using the lightbox parameter as a list. The available options for glightbox can be found at here.

Code
library(pixture)
paths <- c(
  "https://images.pexels.com/photos/572897/pexels-photo-572897.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
  "https://images.pexels.com/photos/7604425/pexels-photo-7604425.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
  "https://images.pexels.com/photos/4666748/pexels-photo-4666748.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
  "https://images.pexels.com/photos/4932184/pexels-photo-4932184.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
  "https://images.pexels.com/photos/4210900/pexels-photo-4210900.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
  "https://images.pexels.com/photos/3126574/pexels-photo-3126574.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
  "https://images.pexels.com/photos/167699/pexels-photo-167699.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
  "https://images.pexels.com/photos/1376201/pexels-photo-1376201.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
  "https://images.pexels.com/photos/7919/pexels-photo.jpg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
  "https://images.pexels.com/photos/2437291/pexels-photo-2437291.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
  "https://images.pexels.com/photos/1679772/pexels-photo-1679772.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
  "https://images.pexels.com/photos/1183099/pexels-photo-1183099.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
  "https://images.pexels.com/photos/1813513/pexels-photo-1813513.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
  "https://images.pexels.com/photos/931018/pexels-photo-931018.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
  "https://images.pexels.com/photos/267074/pexels-photo-267074.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
  "https://images.pexels.com/photos/4622893/pexels-photo-4622893.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"
)
captions <- c(
  "A beautiful night sky filled with stars.",
  "A dense forest with tall trees.",
  "A shark swimming in the ocean.",
  "Coconut trees swaying in the breeze.",
  "A vibrant field of flowers in bloom.",
  "A vast field under a clear sky.",
  "A misty morning in the mountains.",
  "Close-up of green leaves on a tree.",
  "A stunning sunset over the horizon.",
  "Majestic mountains behind an idyllic landscape.",
  "A swamp with lush vegetation.",
  "A rainstorm with dark clouds and lightning.",
  "Raindrops on lush green tropical leaves.",
  "A sandy beach with crystal clear water.",
  "A leopard in snowy weather conditions.",
  "A close-up of a bright sunflower."
)

Clicking on the image opens up the full image in a lightbox. The whole gallery can be browsed through in the lightbox using left or right arrow keys.

pixfigure(paths[1:2], caption = captions[1:2])
pixgallery(paths[1:6], caption = captions[1:6])
pixcarousel(paths[1:6], caption = captions[1:6])

glightbox options can be passed as a list to the lightbox parameter. Below are some examples of customizing the lightbox.

Enable looping of images in the lightbox using loop = TRUE. Zooming can be disabled using zoomable = FALSE.

pixfigure(
  paths[1:2],
  caption = captions[1:2],
  lightbox = list(loop = TRUE, zoomable = FALSE)
)
pixgallery(
  paths[1:6],
  caption = captions[1:6],
  lightbox = list(loop = TRUE, zoomable = FALSE)
)
pixcarousel(
  paths[1:6],
  caption = captions[1:6],
  lightbox = list(loop = TRUE, zoomable = FALSE)
)

1 Session

R version 4.5.1 (2025-06-13)
Platform: aarch64-apple-darwin20.0.0
Running under: macOS Sequoia 15.7.1

Matrix products: default
BLAS/LAPACK: /opt/homebrew/Caskroom/miniforge/envs/r-4.5-arm/lib/libopenblas.0.dylib;  LAPACK version 3.12.0

locale:
[1] C

time zone: Europe/Stockholm
tzcode source: system (macOS)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] pixture_0.2.0

loaded via a namespace (and not attached):
 [1] digest_0.6.37     later_1.4.4       R6_2.6.1          httpuv_1.6.16
 [5] fastmap_1.2.0     xfun_0.54         magrittr_2.0.4    shiny_1.11.1
 [9] knitr_1.50        htmltools_0.5.8.1 rmarkdown_2.30    lifecycle_1.0.4
[13] promises_1.4.0    cli_3.6.5         xtable_1.8-4      compiler_4.5.1
[17] tools_4.5.1       mime_0.13         evaluate_1.0.5    Rcpp_1.1.0
[21] yaml_2.3.10       otel_0.2.0        rlang_1.1.6       jsonlite_2.0.0
[25] htmlwidgets_1.6.4