Feature: #68429 - Introduced AvatarProvider API ¶
See Issue #68429
To make providing an avatar image for BE users more flexible an API has been
introduced so you can register AvatarProviders.
The core provides the
by default to handle the image
defined in the user settings.
When an avatar is rendered in the BE the available
if they can provide an
for the given
record in the requested size. The first
that gets returned is used.
Registering an avatar provider ¶
An avatar provider can be registered within your
file like this:
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend']['avatarProviders']['myCustomProvider'] = [ 'provider' => \MyVendor\MyExtension\AvatarProvider\CompanyAvatarProvider::class, 'before' => ['defaultAvatarProvider'] ];
The settings are defined as:
provider: The avatar provider class name, which must implement
after: You can define the ordering how providers are executed. This is used to get the order in which the providers are executed.
For a new avatar provider you have to register a
If your avatar provider extends another one, you may only overwrite necessary settings. An example would be to
extend an existing provider and replace its registered ‘provider’ class with your new class name.
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend']['avatarProviders']['defaultAvatarProvider']['provider'] = \MyVendor\MyExtension\AvatarProvider\CustomAvatarProvider::class;
The AvatarProviderInterface contains only one method:
The parameters are defined as:
$backendUser: The record from
$size: The requested size of the avatar image.
The return value of the method is expected to be an instance of
when the provider can not provide an image.
object has 3 properties:
$url: Url of avatar image. Needs to be relative to the website root or an absolute URL.
$width: The width of the image.
$height: The height of the image.