Identicon.displayImage() Method

Renders the icon directly to the page output.

public function displayImage(
    string $imageFormat = 'png'
    ) : void


$imageFormat specifies the format of the generated icon. Supported formats are png and svg.


The following code shows how to use displayImage to return an identicon to the client.


$icon = new \Jdenticon\Identicon(array(
    'value' => 'Test icon',
    'size' => 100


The method will set the Content-Type HTTP header. You are recommended to set an appropriate Cache-Control header before calling this method to ensure the icon is cached client side.

The method won't call exit() or die(). Be sure not to write any output to the client before or after this method is called, as it will most likely corrupt the icon.