A Magento 2 module for displaying customer avatars.
-
Install the module via Composer by running the following command in Magento 2 root directory:
composer require kamephis/magento2-avatar
-
Enable the module by running the following command in Magento 2 root directory:
php bin/magento module:enable Kamephis_Avatar
-
Run the following command in Magento 2 root directory:
php bin/magento setup:upgrade
-
Clear the cache by running the following command in Magento 2 root directory:
php bin/magento cache:clean
The Avatar block can be added to any template file by using the following code:
<block class="Kamephis\Avatar\Block\Avatar" name="customer.avatar" template="Kamephis_Avatar::avatar.phtml"/>
Then, you can call the getAvatarHtml() method to get the HTML code for the customer's avatar:
echo $block->getAvatarHtml();
To configure the Avatar module, go to Stores > Configuration > Kamephis > Avatar in the Magento 2 Admin Panel. Here, you can choose the type of avatar to display (Gravatar or Robohash) and the default size of the avatar in pixels.
This module is licensed under the MIT License.