After including the base Services_Libravatar file, create an object of the class. You may set default options for image size, default url, HTTPS mode and hashing algorithm.
After you created the Services_Libravatar instance, call
Services_Libravatar::getUrl()
on it with the email as parameter.
Creating a libravatar instance
<?php
require_once 'Services/Libravatar.php';
$sla = new Services_Libravatar();
$sla->setSize(256)
->setDefault('identicon');
$url = $sla->getUrl('foo@example.org');
?>
Instead of manually deciding if you need HTTPS or not,
Services_Libravatar will detect that automatically when
calling
detectHttps().
If you temporarily need different options for one image, you may
pass them as option array as second parameter to getUrl().
They will override the class options that were configured via the
set*() methods, but only for the current
getUrl() call:
Using temporary options
<?php
require_once 'Services/Libravatar.php';
$sla = new Services_Libravatar();
$sla->setSize(256)
->setDefault('identicon');
$url1Big = $sla->getUrl('foo@example.org');//size 256
$url1Small = $sla->getUrl(
'foo@example.org',
array('size' => 32, 'default' => '404')
);
//size 256 again
$url2Big = $sla->getUrl('bar@example.org');
?>