Hi @prashantvatsh,
At first, I thought your test was different because the default avatar in you example is a static one called “Logo (Gravatar)”, the same for every users, while mine is a dynamic one called “Identicon (generated)”, a different one for every users.
I tried your example on a test server, that worked. Then I tried with my case (generated identicon), that worked too !
Finally I found the reason, in fact the replacement avatar was not coming from the classic “upload a picture”, it was coming from a social plugin (nextend) which retrieves the facebook avatar when you link your WP-account with FB-account, and stores it in the server but in a different folder that buddypress does. (Plus some extra “butterflies” in the DB …)
I reproduced it several times today to understand exactly what is happening, I write it down in case that could help anyone in the future.
What I did first was unlinking the FB-account, but I realized the avatar was still there.
So I clicked on “delete the picture” from my BP-profile page. Success message, but the FB-avatar is still there.
Then I use “inspect element” on my browser. I found his name is “user-99-2-150×150.jpg” and I get the path to the folder too.
First I search that file in the database, I found one “_wp_attachment_metadata” in “postmeta” table. I delete the row.
Here is the point I was stuck on. The picture is gone but there is no more avatar and the header is now above the profile tabs 🙁
Then I went to the server folders, removed the file but what I missed last time is that there are two files 🙄 … “user-99-2-150×150.jpg” & “user-99-2.jpg” … I deleted both, no changes, and I did it so fast, I forgot there was 2.
I really thought the problem was coming from BP/Gravatar.com, I thought the path to my original avatar was lost in the DB (and using a dynamic name).
Finally, thanks to your answer, I just inspected the header again, and found the new avatar link pointing to the second file “user-99-2.jpg” !! Yes !! 🙄
Back to the database to look for this second file and there are two answers :
One “_wp_attachment_metadata” row in “postmeta” table -> deleted. (at this stage the original gravatar is back)
One “attachment” row in “posts” table -> deleted. (no need to keep this row)
The problem is solved. Thanks a lot for your answer, you drove me to the good direction.
Have a nice day 🙂