From 50da651eb061ea8765fba88b6d50f3c1bb0eb75e Mon Sep 17 00:00:00 2001 From: jrycw Date: Sun, 15 Dec 2024 12:20:44 +0800 Subject: [PATCH 1/3] Add missing parentheses to `GT.fmt_image()` --- docs/blog/rendering-images/index.qmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/blog/rendering-images/index.qmd b/docs/blog/rendering-images/index.qmd index 4392e3038..591af8b5f 100644 --- a/docs/blog/rendering-images/index.qmd +++ b/docs/blog/rendering-images/index.qmd @@ -10,7 +10,7 @@ format: code-summary: "Show the Code" --- -Rendering images in Great Tables is straightforward with `GT.fmt_image` and `vals.fmt_image()`. +Rendering images in Great Tables is straightforward with `GT.fmt_image()` and `vals.fmt_image()`. In this post, we'll explore three key topics: * Four examples demonstrating how to render images within the body using `GT.fmt_image()`. From 124cc1c07d704bbeb90751925400cf9f0140e6f6 Mon Sep 17 00:00:00 2001 From: jrycw Date: Sun, 15 Dec 2024 12:22:57 +0800 Subject: [PATCH 2/3] Update docstring for the `vals.fmt_image()` --- great_tables/_formats_vals.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/great_tables/_formats_vals.py b/great_tables/_formats_vals.py index e4482f9dc..cff8b0cc3 100644 --- a/great_tables/_formats_vals.py +++ b/great_tables/_formats_vals.py @@ -986,7 +986,8 @@ def val_fmt_image( In the output of images within a body cell, `sep=` provides the separator between each image. path - An optional path to local image files (this is combined with all filenames). + An optional path to local image files or an HTTP/HTTPS URL. + This is combined with the filenames to form the complete image paths. file_pattern The pattern to use for mapping input values in the body cells to the names of the graphics files. The string supplied should use `"{}"` in the pattern to map filename fragments to From 4f7202d477b3cd180bd51d267456c9b247022f33 Mon Sep 17 00:00:00 2001 From: jrycw Date: Mon, 16 Dec 2024 09:15:21 +0800 Subject: [PATCH 3/3] Rename logo URLs to avoid list indexing in the example --- docs/blog/rendering-images/index.qmd | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/docs/blog/rendering-images/index.qmd b/docs/blog/rendering-images/index.qmd index 591af8b5f..167a72502 100644 --- a/docs/blog/rendering-images/index.qmd +++ b/docs/blog/rendering-images/index.qmd @@ -287,9 +287,9 @@ metro_mini ### Single Image This example shows how to render a valid URL as an image in the title of the table header: ```{python} -logo_url = "https://posit-dev.github.io/great-tables/assets/GT_logo.svg" +gt_logo_url = "https://posit-dev.github.io/great-tables/assets/GT_logo.svg" -_gt_logo, *_ = vals.fmt_image(logo_url, height=100) # <1> +_gt_logo, *_ = vals.fmt_image(gt_logo_url, height=100) # <1> gt_logo = html(_gt_logo) ( @@ -307,10 +307,8 @@ item from the list. This example demonstrates how to render two valid URLs as images in the title and subtitle of the table header: ```{python} -logo_urls = [ - "https://posit-dev.github.io/great-tables/assets/GT_logo.svg", - "https://raw.githubusercontent.com/rstudio/gt/master/images/dataset_metro.svg", -] +metro_logo_url = "https://raw.githubusercontent.com/rstudio/gt/master/images/dataset_metro.svg" +logo_urls = [gt_logo_url, metro_logo_url] _gt_logo, _metro_logo = vals.fmt_image(logo_urls, height=100) # <1> gt_logo, metro_logo = html(_gt_logo), html(_metro_logo) @@ -335,8 +333,8 @@ previous table can be created without relying on `vals.fmt_image()` like this: GT(metro_mini) .fmt_image("lines", path=img_url_paths, file_pattern="metro_{}.svg") .tab_header( - title=html(f''), - subtitle=html(f''), + title=html(f''), + subtitle=html(f''), ) .cols_align(align="right", columns="lines") .opt_stylize(style=4, color="gray")