avatar - get_avatar_url() how to reset the default image

admin2025-01-07  6

I use the get_avatar_url() to retrieve the default gravatar image of an user.

get_avatar_url( $user_id );

In case there is non I will provide and default using the arguments array.

$arg = array (
'default' => get_home_url() . '/wp-content/uploads/.../profile_image_0.jpg',
);

$avatar = get_avatar_url( $user_id , $arg );

This is working fine until I need to replace the image. The problem is that the "" service is caching the image.

So the question is how to reset or exchange the image without changing the filename?

I use the get_avatar_url() to retrieve the default gravatar image of an user.

get_avatar_url( $user_id );

In case there is non I will provide and default using the arguments array.

$arg = array (
'default' => get_home_url() . '/wp-content/uploads/.../profile_image_0.jpg',
);

$avatar = get_avatar_url( $user_id , $arg );

This is working fine until I need to replace the image. The problem is that the "https://i1.wp.com" service is caching the image.

So the question is how to reset or exchange the image without changing the filename?

Share Improve this question asked Jun 3, 2019 at 11:11 user3361559user3361559 151 silver badge5 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Paste below code in function.php file

function theme_custom_avatar_url($url, $idOrEmail, $args){

    return get_home_url() . '/wp-content/uploads/.../profile_image_0.jpg';
}
add_filter('get_avatar_url', 'theme_custom_avatar_url', 10, 3);
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736253902a161.html

最新回复(0)