Renders the icon and returns the icon as a data URI.
public function getImageDataUri( string $imageFormat = 'png' ) : string
$imageFormat specifies the format of the generated icon. Supported formats are
The following code shows how to use
getImageDataUri to insert an identicon into the html markup. Remember that the performance is degraded by using
getImageDataUri, since no icons are cached.
<?php include_once('vendor/autoload.php'); $icon = new \Jdenticon\Identicon(array( 'value' => 'Test icon', 'size' => 100 )); ?> <!DOCTYPE html> <html> <head> <title>Identicon test</title> </head> <body> An identicon: <br> <img src="<?php echo $icon->getImageDataUri('svg') ?>" alt="Identicon"> </body> </html>
It is recommended to avoid using this method unless really necessary, since it will effectively disable client caching of generated icons, and will also cause the same icon to be rendered multiple times, when used multiple times on a single page.
An alternative is to create a separate php file whose purpose is only to serve identicons. Let the file accept query string parameters for icon size and value, and serve the icon with a really high
max-age in the