Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Gravatar Bundle

Gravatar Bundle Laravel Package

ornicar/gravatar-bundle

A lightweight Symfony bundle for integrating Gravatar avatars. It provides a Twig helper and service to generate Gravatar URLs with configurable size, rating, and default image settings, making it easy to add user profile avatars to your templates and services.

View on GitHub
Deep Wiki
Context7

OrnicarGravatarBundle is a lightweight Symfony bundle that generates Gravatar avatar URLs from email addresses. It registers a configurable service plus Twig helpers, so you can output correctly hashed, size- and rating-aware avatar links from templates or PHP without repeating boilerplate.

  • gravatar() Twig function and filters for building avatar URLs
  • Automatic MD5 hashing of email addresses
  • Bundle-level defaults for size, rating, default image, and secure URLs
  • Per-call overrides for any parameter
  • Integration with Symfony's DI container and configuration
Frequently asked questions about Gravatar Bundle
Can I use ornicar/gravatar-bundle in a Laravel application?
No. Despite the Composer framing, ornicar/gravatar-bundle (henrikbjorn/GravatarBundle) is a Symfony bundle that depends on Symfony bundle registration, container service tagging, and a Twig extension. Laravel's service provider and Blade model do not map onto those conventions without a rewrite. The underlying behavior is only about 30 to 50 lines of PHP, so reimplementing it in Laravel is faster and lower risk than adapting the bundle.
What does ornicar/gravatar-bundle actually do?
It hashes an email address with md5(strtolower(trim($email))) and assembles a Gravatar avatar URL with configurable size, rating, and default-image query parameters. It exposes that logic as a Symfony service plus a Twig template helper. There is no avatar uploading, caching, or storage involved.
How do I install ornicar/gravatar-bundle?
For legacy Symfony projects it was installed with Composer and registered in AppKernel.php or config/bundles.php depending on the Symfony version. There is no Laravel installation path and no Laravel service provider. Because the last release was 2018-04-29, installing it in a new project is not recommended even on Symfony.
Does ornicar/gravatar-bundle support PHP 8.2 and modern Laravel versions?
It has no declared compatibility with PHP 8.1, 8.2, or 8.3, and no Twig 3 alignment work was done. The code originates from the PHP 5.6 and 7.x era, so expect deprecation notices or fatal errors on modern runtimes without patches. Laravel support is not applicable because the package is Symfony-only. Run PHPStan or Psalm against PHP 8.2 before considering it even in a Symfony context.
What is the best Laravel alternative to ornicar/gravatar-bundle?
Write a small internal AvatarService and bind it through a Laravel ServiceProvider, then expose it with a gravatar() Blade directive. The service only needs to normalize the email, compute the MD5 hash, and build the query string. Add a simple cache and an initials-based fallback so the Gravatar path is one implementation among several. This removes the third-party dependency entirely.
How do I generate a Gravatar URL from an email address in Laravel?
Normalize the email with strtolower and trim, hash it with md5, and append it to https://www.gravatar.com/avatar/. Add the s parameter for size in pixels, r for rating (g, pg, r, or x), and d for the default image. Wrap it in a helper or Blade directive so views stay clean. This is roughly a one-liner plus a query-string builder.
How do I handle the default avatar when a user has no Gravatar?
Use the d query parameter with values such as identicon, monsterid, retro, wavatar, mp, or 404, or pass a URL-encoded custom image. Many users have no Gravatar, so the mystery-person default is a known UX downgrade. A local initials-based or uploaded-image fallback is usually better than relying on Gravatar's defaults. Combining d= with your own fallback gives the most consistent result.
Is ornicar/gravatar-bundle safe to use in production in 2024?
Not recommended. The repository is archived, the last release was 2018-04-29, there is no security response path, and it has zero dependents. Since the functionality is trivial, reproducing it in-house is the lower-risk path for both Laravel and modern Symfony. If you inherit it in a legacy Symfony app, pin the version and treat it as frozen code behind your own interface.
How does the bundle handle size, rating, and default image configuration?
It maps bundle configuration to Gravatar query parameters: s for size in pixels (1 to 2048), r for the rating ceiling (g, pg, r, or x), and d for the default image. It can also set forcedefault. Replicating this is a straightforward query-string builder in your own service, which is why the bundle adds little long-term value.
Is ornicar/gravatar-bundle still maintained?
No. The repository is archived and the last release was published on 2018-04-29, with no active maintainer and no downstream dependents reporting bugs. There is no PHP 8.x or Twig 3 modernization work in progress. Treat it as abandoned and either replace it with a small internal implementation or wrap it behind an AvatarProvider interface you control.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console