Download the PHP package tourze/user-avatar-bundle without Composer
On this page you can find all versions of the php package tourze/user-avatar-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package user-avatar-bundle
User Avatar Bundle
中文
A Symfony bundle that provides user avatar services with support for custom avatars, Gravatar integration, and fallback to default avatars.
Features
- Custom Avatar Support: Display user-uploaded avatars when available
- Gravatar Integration: Automatically generates Gravatar URLs based on user email
- Default Avatar Fallback: Shows default avatar when user has no custom avatar or email
- Configurable Sizes: Supports different avatar sizes (default 128px)
- Extensible Interface: Easy to extend with custom avatar implementations
Installation
Quick Start
-
Add the bundle to your
config/bundles.php: -
Configure the default avatar URL in your environment:
- Use the avatar service in your application:
Configuration
Environment Variables
DEFAULT_USER_AVATAR_URL: URL to the default avatar image used as fallback
User Entity Requirements
Your user entity should implement the following methods to work with this bundle:
Avatar Resolution Priority
The service resolves avatar URLs in the following order:
- Custom Avatar: If user has a custom avatar URL, it's returned
- Gravatar: If user has an email, generates Gravatar URL with the email hash
- Default Avatar: Falls back to the configured default avatar URL
API Reference
AvatarServiceInterface
getLink(?UserInterface $user, int $size = 128): string
Returns the avatar URL for the given user.
Parameters:
$user: User object (can be null for default avatar)$size: Avatar size in pixels (default: 128)
Returns: Avatar URL string
syncAvatarToLocal(UserInterface $user): void
Synchronizes user avatar to local storage (currently not implemented).
Testing
Run the test suite:
Contributing
Please see CONTRIBUTING.md for details.
License
The MIT License (MIT). Please see License File for more information.
All versions of user-avatar-bundle with dependencies
ext-hash Version *
symfony/config Version ^7.3
symfony/dependency-injection Version ^7.3
symfony/framework-bundle Version ^7.3
symfony/http-kernel Version ^7.3
symfony/property-access Version ^7.3
symfony/security-core Version ^7.3
symfony/service-contracts Version ^3.6
symfony/yaml Version ^7.3
tourze/symfony-dependency-service-loader Version 1.0.*