Support » Plugin: Add Local Avatar » [Plugin: Add Local Avatar] Fix for problem with uploading avatar images

  • Like a lot of people here, I couldn’t get this plugin to successfully upload and display local avatar images. After looking back through the comments of other people posting the same complaint and following some other links, I found this solution by baldgoat. It requires changing code in the PHP file, which could be scary for people who have no idea what they’re doing, so I have included step-by-step instructions on what to do.

    1) Deactivate the plugin.

    2) Click on the Edit link for the plugin. The file you want to edit is avatar.php.

    3) Find the following line of code:

    return substr(ABSPATH, 0, -strlen(strrchr(substr(ABSPATH, 0, -1), ‘/’)) – 1);

    4) Comment it out by adding // in front of it. This is so that you can undo the changes if you need to.

    5) Below that line insert this line:

    return ABSPATH;

    6) Find the following code (under the comment “Try to use local avatar.”):

    if($id) {
    $local = get_usermeta($id, ‘avatar’);
    if(!empty($local)) {
    $src = $local;
    $avatar_type = TYPE_LOCAL;
    }
    }

    7) Replace it with:

    if($id) {
    $local = get_usermeta($id, ‘avatar’);
    if (!empty ($local)) {
    $local = get_bloginfo(‘url’).$local;
    }
    if(!empty($local)) {
    $src = $local;
    $avatar_type = TYPE_LOCAL;
    }
    }

    8) Click on Update File.

    9) Reactivate the plugin and go to its admin screen.

    10) In the User Uploads section, you should notice that, if your WordPress site is in a subdirectory, the subdirectory name is now showing in the directory address that follows “If allowed, use this directory for user avatar uploads, e.g. /avatars. Must have write access and is relative to…” You might have to hit Reload/Refresh first to see it.

    11) Make sure that “Or, use legacy (v7.3 and lower) $_SERVER[‘DOCUMENT_ROOT’] method” is NOT checked and that the User Uploads checkbox is checked.

    12) Enter the location of the folder where you want the avatar files to be put (mine is /wp-content/uploads/avatars/).

    13) If you haven’t already done so, make sure that the permissions of the avatars folder is set to 755 so that it can be written to. (Note: Some hosts may require that you set the permissions to 777.)

    Now go to your profile and upload a new avatar so you can test it out. After doing these things, the plugin works fine for me in 3.3.2. Hopefully, it will work for you as well.

    http://wordpress.org/extend/plugins/add-local-avatar/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thank you, now the plugin doesn’t upload at all….

    After messing around I fixed the problem, no codes needed to be changed. I just used /wp-content/uploads/avatars Chmod 777 and enabled legacy (v7.3 and lower).

    I’m glad to hear that. That did not work for me. I guess different fixes work for different situations. People should definitely try what you did first.

    As I said before, this is not my fix. I’m only posting here what I found in another post. You’ll find the original post at:

    http://wordpress.org/support/topic/plugin-add-local-avatar-finally-got-it-to-work?

    At first i’ve tried brenosilver’s fix and it does not work for me, it just gives me the “Upload error: Upload directory doesn’t exist.”

    I’ve tried all other methods of changing the link a

    I’ve then tried MaureenT method and it works.

    A lot of thanks to all!

    Thanx MaureenT that worked for me too.

    Azurite

    (@azurite)

    I’m using WordPress Multisite with 3.4.2…I don’t see the Avatar/Get Local Avatar’s admin screen. Where would I see it? It’s not accessible from the plugin page from either the Network Admin dashboard or an individual site’s dashboard (I’m logged in as a super-admin)

    ETA: Nevermind, found it in Settings > Avatars.

    But though I successfully managed to upload an image for another site of mine (another user) on my Multisite install, it doesn’t show up when I go to Settings > Avatar, though it does display when I manage the Avatar for that user. Should I be worried? I’m not allowing user uploads for others; I’m the only one who’ll be managing avatars and users for these sites.

    Thanks MaureenT!

    Plugin Author peterwsterling

    (@peterwsterling)

    There are NO CODE CHANGES required, it is a case of configuring the plugin correctly in your specific WP and hosting environment!

    Ok If there is no need for CODE CHANGE, how to fix it?

    All Avatars uploaded after 13th February are suddenly broken…

    So many people are having this problem and you are answering

    “There are NO CODE CHANGES required, it is a case of configuring the plugin correctly in your specific WP and hosting environment!”… bla bla

    still no answer… any solution. I need urgent fix.
    Plugin path was working perfectly until last update. All uploads after update are broken.
    Link for image is created on correct /avatars location, but image is broken.
    How to fix it?

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Plugin: Add Local Avatar] Fix for problem with uploading avatar images’ is closed to new replies.