Adding the add_image_ext() function#8
Open
feddelegrand7 wants to merge 1 commit into
Open
Conversation
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 |
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>
There was a problem hiding this comment.
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 anhtmltools::img()tag pointing athttps://picsum.photos/...(optionally seeded). - Exports the new function and adds generated Rd documentation.
- Adds
glueandhtmltoolsto 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.
| #' | ||
| #' 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 on lines
+23
to
+24
| htmltools::img(src = glue::glue("https://picsum.photos/seed/{seed}/{width}/{height}")) | ||
|
|
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 on lines
8
to
11
| export(random_ggplotly) | ||
| export(random_image) | ||
| export(random_image_ext) | ||
| export(random_lm) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.