diff --git a/DESCRIPTION b/DESCRIPTION index af6527b..a924885 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -30,7 +30,9 @@ Imports: magrittr, plotly, stats, - utils + utils, + glue, + htmltools Suggests: testthat Encoding: UTF-8 diff --git a/NAMESPACE b/NAMESPACE index 69040ae..43df64e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -7,6 +7,7 @@ export(random_dygraph) export(random_ggplot) export(random_ggplotly) export(random_image) +export(random_image_ext) export(random_lm) export(random_print) export(random_table) diff --git a/R/random_image_ext.R b/R/random_image_ext.R new file mode 100644 index 0000000..4f2b953 --- /dev/null +++ b/R/random_image_ext.R @@ -0,0 +1,28 @@ +#' A Random External Image from the Lorem Picsum API +#' +#' 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 +#' +#' @export +#' +#' @examples +#' +#' random_image_ext(width = 400, height = 600, seed = "caramba") +#' +#' + +random_image_ext <- function(width = 400, height = 400, seed = NULL) { + + if (is.null(seed)) { + + htmltools::img(src = glue::glue("https://picsum.photos/{width}/{height}")) + + } else { + + htmltools::img(src = glue::glue("https://picsum.photos/seed/{seed}/{width}/{height}")) + + } + + +} diff --git a/man/random_image_ext.Rd b/man/random_image_ext.Rd new file mode 100644 index 0000000..9930d5c --- /dev/null +++ b/man/random_image_ext.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/random_image_ext.R +\name{random_image_ext} +\alias{random_image_ext} +\title{A Random External Image from the Lorem Picsum API} +\usage{ +random_image_ext(width = 400, height = 400, seed = NULL) +} +\value{ +an external image +} +\description{ +This function returns an external random image from the Lorem Picsum API that can be used directly within the Shiny UI. +} +\examples{ + +random_image_ext(width = 400, height = 600, seed = "caramba") + + +}