Closed SCasanova closed 2 years ago
Howdy @SCasanova, thanks for the report!
Can you provide a reprex
of the behavior? Is it an issue with resizing the table or the images themselves are scaled differently?
As far as I understand, table-based auto-resizing would likely require javascript which I likely do not have the skillset to enable.
For more generic sizing of images, I can try playing around with percentages eg height='15%'
, but that may lead to some undesirable behavior.
Yes, it's more a feature request than it is an issue per se.
I think the option for the image to be auto-sized to the table would be useful in many applications but I understand if it's not something realistic at the moment
Howdy @SCasanova - I might be missing the issue here.
When using differently sized width/height images they are normalized to a shared height with varying widths (since the images are wider or narrower).
library(gt)
base_tab <- dplyr::tibble(
a = 1, b = 2, c = 3
) %>%
gt()
test_img <- base_tab %>%
cols_label(
a = gtExtras::img_header("3 brownies", "https://i.imgur.com/tI5jq2c.jpg"),
b = gtExtras::img_header("5 waffles", "https://i.imgur.com/37w80TG.jpg"),
c = gtExtras::img_header("1 cake bite", "https://i.imgur.com/B1MCOtx.jpg")
) %>%
gtExtras::gtsave_extra("test.png", selector = "table")
magick::image_read("test.png")
tab1 <- base_tab %>%
tab_header(title = gtExtras::img_header("3 brownies", "https://i.imgur.com/tI5jq2c.jpg")) |>
gtExtras::gtsave_extra("head1.png", selector = "table")
tab2 <- base_tab %>%
tab_header(title = gtExtras::img_header("5 waffles", "https://i.imgur.com/37w80TG.jpg")) %>%
gtExtras::gtsave_extra("head2.png", selector = "table")
img1 <- magick::image_read("head1.png")
img2 <- magick::image_read("head2.png")
magick::image_append(c(img1, img2))
Created on 2022-05-26 by the reprex package (v2.0.1)
Closing for now as I believe it's working for different sized images.
For shiny applications it would be useful to be able to set auto for either of those properties so different images fit the table header.