See updates below. I upgraded to 3.7.1 using svn. I did this on my localhost first to make sure everything is fine. Everything was, so I proceeded to do it on the server. However, on the server, the users’ avatars are not showing up and instead everyone is getting Gravatar’s mystery man.
Here is the code I have in my functions.php:
<?php switch ( $comment->comment_type ) :
case '' :
?>
<p <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
<div id="comment-<?php comment_ID(); ?>">
<?php echo get_avatar( $comment, 40 ); ?>
When I look at the source of the generated page on my localhost for the above I get the following code:
<img src="http://localhost/[path]/wp-content/uploads/avatars/[a number]/[imagename.jpg]"
On the server when I view source I get the following code for the same user:
<img src="http://gravatar.com/avatar/[alphanumeric]=http://[mywebsite.com]/wp-content/plugins/buddypress/bp-core/images/mystery-man.jpg[code]"
I must be making a mistake somewhere but for the life of me I cannot figure it out. The only explanation I can come up with is that Gravatar is not accepting requests from localhost and that is why it is working the way I would like it to on my localhost.
So what do I have to do to make their local avatars show up (the ones they uploaded themselves)? I should also add that I am using the BuddyPress plugin (both on localhost and server).
Aside from that, is there a technique people use to compare the files on the server with those on the development machine? Something akin to vimdiff?
UPDATE: I copied the localhost directory recursively using cp -r
to another directory. I then rsynced that directory with the remote server making it a mirror of the server. Then I ran diff -NbBiwr /path/to/localhost /path/to/localhostCopyThatWasRsynced
and received no major differences save for stuff in the .svn
directories. When I view the copied version in a browser the local avatars show up. This is really starting to make no sense at all. I also updated the sql database to reflect the one on the remote server and the local avatars show up on localhost but not on the remote server.
UPDATE 2: Here are all the things I attempted since the last update:
- Toggle
wp-debug
to true. No errors of note. - Removed the entire directory, did a new
svn co
. - Deactived all other plugins besides BuddyPress.
- Used the default BuddyPress theme.
- Installed version 3.6.1 (the last good version I used).
- Checked and rechecked directory permissions.
- I removed the avatars directory and when someone tries to upload an avatar it creates the avatars directory and the userid subdirectory but the image does not upload. The subdirectory remains blank. This is the error that is returned on the front end
Upload Failed! Error was: Unable to create directory wp-content/uploads/avatars/1407/avatars/1407. Is its parent directory writable by the server?
As you can see it duplicates the avatars directory and the userid subdirectory for some reason. This happens on both the server and localhost. Localhost is displaying avatars properly however. - Tinkered with birgire’s suggestions below. Nothing.
Debug ideas:
You could try to see if this has any effect:
But you should check out the parameters that go through the
bp_core_fetch_avatar
filter to see if they are correct (untested):where you have to modify the path to your writeable
debug.log
file.The file should then contain lines like this one:
I updated the above debug code, to take into account that
$params
is an array.Some general remarks:
It’s interesting to look into the file
/bp-core/bp-core-avatars.php
.The avatar image seems to be overwritten via this filter:
and inside the
bp_core_fetch_avatar_filter()
callback you have this line:and it was inside that function, I found the applied
bp_core_fetch_avatar
filter.So I think these functions might be worth debugging further or maybe you could try to correct the avatars via the above
bp_core_fetch_avatar
filter?It turns out there was something wrong with the uploads folder. If anybody has this issue in the future, this is what to do.
chmod 777 uploads/
chmod 775 uploads/
That was all it was.