Replace Gravatar

I have just added two new filter hooks so from next version you will be able to do something like this from an extension:
PHP:
Yii::app()->hooks->addFilter('customer_get_gravatar_url', function($currentAvatarUrl, $customer, $size){
    return '//www.gravatar.com/avatar/'.  md5($customer->email) .'?d=identicon&s=' . $size;
});
Yii::app()->hooks->addFilter('user_get_gravatar_url', function($currentAvatarUrl, $user, $size){
    return '//www.gravatar.com/avatar/'.  md5($user->email) .'?d=monsterid&s=' . $size;
});
But just from next version...
 
Hi, were you able to change the default avatar?
Use those filters as specified above.
Create a file called apps/init-custom.php and put the hooks into it:
PHP:
<?php
    
hooks()->addFilter('customer_get_gravatar_url', function($currentAvatarUrl, $customer, $size){
    return '//www.gravatar.com/avatar/'.  md5($customer->email) .'?d=identicon&s=' . $size;
});

hooks()->addFilter('user_get_gravatar_url', function($currentAvatarUrl, $user, $size){
    return '//www.gravatar.com/avatar/'.  md5($user->email) .'?d=monsterid&s=' . $size;
});
 
Back
Top