I think I found the solution, for wordpress sites installed with cpanel, this line does not work:
$wp_user_avatar_id = get_user_meta( $user_id, $wpdb->get_blog_prefix() . 'user_avatar', true );
Replacing the direct table name("wp_user_avatar") has started detecting images.
$wp_user_avatar_id = get_user_meta( $user_id, 'wp_user_avatar', true );
can you test with others installations.
Regards and thanks.
Darío