I found the answer to your question.
I’ve created a simple avatar plugin. (I edited and developed the code)
if ( !function_exists( 'get_avatar' ) ) :
function get_avatar( $id_or_email, $size="0", $default="", $alt = false ) {
if ( ! get_option('show_avatars') )
return false;
static $default_url;
if ( !isset( $default_url ) ) $default_url="http://example.com/image/my-image.png" ;
if ( false === $alt)
$safe_alt="";
else
$safe_alt = esc_attr( $alt );
if ( !is_numeric( $size ) )
$size="0";
$avatar = "<img alt="{$safe_alt}" src="https://wordpress.stackexchange.com/questions/315430/{$default_url}" class="avatar avatar-{$size} photo avatar-default" height="{$size}" width="{$size}" />";
return apply_filters( 'get_avatar', $avatar, $id_or_email, $size, $default, $alt );
}
endif;
function __limit_default_avatars_setting( $default )
{
}
add_filter( 'avatar_defaults', '__limit_default_avatars' );
?>
I chose to take the image directly from the directory.
get_template_directory_uri()
instead
$default_url =
it was logical to use this code. because the other is redirecting to wordpress cdn url. (just like in emoji and svg profiles)