Skip to content

Adding the add_image_ext() function#8

Open
feddelegrand7 wants to merge 1 commit into
ThinkR-open:masterfrom
feddelegrand7:random_image_ext
Open

Adding the add_image_ext() function#8
feddelegrand7 wants to merge 1 commit into
ThinkR-open:masterfrom
feddelegrand7:random_image_ext

Conversation

@feddelegrand7
Copy link
Copy Markdown

Hi,

the add_image_ext() function can be useful in the sense that it generate a random image from the Lorem Picsum API which can be implemented directly within the Shiny User Interface for quick prototyping.

Best.

@VincentGuyader
Copy link
Copy Markdown
Member

Thanks a lot for this @feddelegrand7, and sorry for the very long delay! 🙏

I've picked it up in #17 — same feature, with input validation, URL-encoding of the seed, a test suite, and without the extra glue dependency. You're kept as Co-authored-by on the commit. This PR will be closed automatically once #17 is merged.

VincentGuyader added a commit that referenced this pull request May 12, 2026
Reworked from PR #8: drop the glue dependency (use sprintf), validate
width/height/seed, URL-encode the seed, document that no network request
is made, add a full test suite. htmltools added to Imports (used by
htmltools::img); utils import is now actually used (URLencode).

TDD: tests/testthat/test-image-ext.R written first (red), then implementation.

Co-authored-by: feddelegrand7 <ihaddaden.fodeil@gmail.com>
@VincentGuyader VincentGuyader requested a review from Copilot May 12, 2026 12:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new exported helper to embed a random external image from the Lorem Picsum API in Shiny UIs, extending the existing “random_*” prototyping utilities in the package.

Changes:

  • Introduces random_image_ext() to generate an htmltools::img() tag pointing at https://picsum.photos/... (optionally seeded).
  • Exports the new function and adds generated Rd documentation.
  • Adds glue and htmltools to package imports.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.

File Description
R/random_image_ext.R Implements the new random_image_ext() helper and roxygen docs.
NAMESPACE Exports random_image_ext.
man/random_image_ext.Rd Adds the generated documentation for the new function.
DESCRIPTION Adds glue and htmltools as Imports for the new helper.
Files not reviewed (1)
  • man/random_image_ext.Rd: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread R/random_image_ext.R
#'
#' This function returns an external random image from the Lorem Picsum API that can be used directly within the Shiny UI.
#'
#' @return an external image
Comment thread R/random_image_ext.R
Comment on lines +23 to +24
htmltools::img(src = glue::glue("https://picsum.photos/seed/{seed}/{width}/{height}"))

Comment thread R/random_image_ext.R
Comment on lines +15 to +19
random_image_ext <- function(width = 400, height = 400, seed = NULL) {

if (is.null(seed)) {

htmltools::img(src = glue::glue("https://picsum.photos/{width}/{height}"))
Comment thread NAMESPACE
Comment on lines 8 to 11
export(random_ggplotly)
export(random_image)
export(random_image_ext)
export(random_lm)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants