Gravatar engine
Name: gravatar. Output: a Gravatar URL. Content type: image/png.
The engine hashes the seed (treated as an email: lowercased and trimmed, then
MD5) and builds a https://www.gravatar.com/avatar/{hash} URL with query
parameters. It does not perform a network request itself; it returns the URL.
Avatar::engine('gravatar')
->seed('user@example.com')
->size(256)
->defaultImage('identicon')
->rating('g')
->generate()
->toUrl();
Options
| Option | Method | Gravatar parameter | Default |
|---|---|---|---|
| Default image | defaultImage() | d | mp |
| Rating | rating() | r | g |
The avatar size becomes the s parameter. f=y (force default) is always sent.
defaultImage accepts the standard Gravatar values: 404, mp, identicon,
monsterid, wavatar, retro, robohash, blank. Setting it to 404 makes
Gravatar return an error when no profile image exists, which is useful in a
fallback chain.
rating accepts g, pg, r, or x.
Fallback note
Because the engine returns a URL without verifying that an image exists, it does
not decline on a missing profile image on its own. Combine defaultImage('404')
with a downstream local engine if you want a real fallback when the user has no
Gravatar.