Set image formatter
Usage
set_formatter_image(
widget,
columns,
height = "50px",
width = "50px",
url_prefix = NULL,
url_suffix = NULL,
hoz_align = "center"
)
Arguments
- widget
A
tabulator()
HTML widget.- columns
The names of the columns the formatter is applied to.
- height
(character): A CSS value for the height of the image.
- width
(character): A CSS value for the width of the image.
- url_prefix
(character): String to add to the start of the cell value when generating the image src url.
- url_suffix
(character): String to add to the end of the cell value when generating the image src url.
- hoz_align
(character): The horizontal alignment of the column.
Value
The updated tabulator()
HTML widget
Examples
image_url <- "https://picsum.photos/id/"
image_size <- 100
image_data <- data.frame(
image = c(88, 98, 102, 201),
label = c("Pic No. 88", "Pic No. 98", "Pic No. 102", "Pic No 201")
)
tabulator(image_data, tabulator_options(height = "400px")) |>
set_formatter_image(
"image",
height = image_size,
width = image_size,
url_prefix = image_url,
url_suffix = glue::glue("/{image_size}"),
hoz_align = "left"
)