Skip to content

as_raw_html() doesn't include images #837

@bzigterman

Description

@bzigterman

When I run the code below to make an html table with gt, the images appear fine in Rstudio's viewer, but when I run them through as_raw_html, the image references don't make it into the html. Unless I'm doing something wrong, this appears to be a bug in gt.

This also happens when I use local_image. Curiously, it doesn't happen when I add inline_css = FALSE to as_raw_html.

library(gt)
library(tidyverse)

standings_table <-
  dplyr::tibble(
    pixels = px(seq(10, 35, 5)),
    image = seq(10, 35, 5)
  ) %>%
  gt() %>%
  text_transform(
    locations = cells_body(columns = image),
    fn = function(x) {
      web_image(
        url = "https://www.mlbstatic.com/team-logos/142.svg",
        height = as.numeric(x)
      )
    }
  )

standings_table
standings_table_html <- as_raw_html(standings_table)
standings_table_html

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions