Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override get_avatar_url() #5

Open
aslakr opened this issue Dec 4, 2019 · 5 comments
Open

Override get_avatar_url() #5

aslakr opened this issue Dec 4, 2019 · 5 comments

Comments

@aslakr
Copy link
Author

aslakr commented Dec 4, 2019

I suppose bp_gravatar_url is similar only for BuddyPress, but get_avatar_url() (and get_avatar_data()) was introduced later in WordPress 4.2 (in 2015)?

add_filter('bp_gravatar_url', array($libravatarReplace, 'filterBPGravatarUrl', 10));

public function filterBPGravatarUrl()
{
$default_host = 'https://seccdn.libravatar.org/avatar/';
if (empty($this->bp_catched_last_email)) {
return $default_host;
}
$libravatar = $this->getLibravatarClass();
$options = array();
$options['algorithm'] = 'md5';
$options['https'] = $this->isSsl();
$url = $libravatar->getUrl($this->bp_catched_last_email, $options);
preg_match('~^(.*/avatar/)~', $url, $matches);
return isset($matches[1]) ? $matches[1] : $default_host;
}

@sunchaserinfo
Copy link
Owner

There are new (pre_)get_avatar_data filters which look perfect for new injection

@aslakr
Copy link
Author

aslakr commented Dec 13, 2022

The same applies when using @pfefferle pfefferle/wordpress-activitypub, i.e. Mastadon will use gravatar instead of federated libravatar.

Do you have any suggestion on how the code should be changed to use the (pre_)get_avatar_data filters?

@pfefferle
Copy link

pre_get_avatar_data is what we are using for Webmentions:

@sunchaserinfo
Copy link
Owner

Anyone care to take over the plugin?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants