Skip to:
Content
Pages
Categories
Search
Top
Bottom

Plugin: Avatar Upload


  • LMD
    Participant

    @louisedade

    Although there are already two avatar plugins available, they require that users either have their own webspace to store an avatar or use one of the avatar services (e.g. Gravatar).

    My users do not have either of those things, so I wrote an avatar upload plugin. Besides offering avatar hosting, it also allows you more control over the type and content of avatars than simply providing a link to an offsite image.

    Features

    • Bozos can not upload avatars.
    • Admins can configure the maximum allowed file size (bytes) and dimensions (pixels) of images.

      • Currently done from within the script (no Admin page interface at this time).

    • Anybody with the ‘moderate’ capability can upload another user’s avatar.

      • This ensures that inappropriate images can be removed.
      • There is no “delete avatar” function at this time, but an inappropriate image can be removed by uploading a ’safe’ image (e.g. a blank 1×1 pixel image) to replace it (you could then manually set that user as a bozo to stop them re-uploading inappropriate images.

    • File checking is carried out to ensure that:

      • The file has a valid extension (.gif, .jpeg, .jpeg, .png)
      • The file has a valid content-type (’image/gif’, ‘image/jpeg’, ‘image/png’)
      • The file extension and content-type actually match.
      • Other checks for filesize, image dimensions, etc.

    More info and ZIP download: bbPress Plugin: Avatar Upload

    I will be submitting this avatar to the bbPRess Plugin Repositry too.

Viewing 25 replies - 76 through 100 (of 128 total)
  • Thanks… I’ll wait for the update then =)


    LMD
    Participant

    @louisedade

    Avatar Upload version 0.8.1 is now available.

    * This version enables the resizing of transparent GIFs and PNGs. Note, PNG alpha channel transparencies may cause problems.

    * It also makes a bit better use of the cache using bb_get_user().

    * A tiny HTML error was fixed on the upload avatar template.

    That was quick! You are great!

    On a side note…. when I download the zip file, 2 of the files in the additional-files directory are 0 length. I can grab them off the svn, so it’s not a big deal, but you might want to check that.


    LMD
    Participant

    @louisedade

    Arrrrggghhh! Not again! Sorry, this happened with the last update and I don’t know what the problem is. The files are there in the SVN, so something is going wrong with the automatic ZIP downloader. I’m going to fire off an email to the bbDev list.

    Also, I posted the announcement a little prematurely. Version 0.8.1 hasn’t appeared in the Plugin browser yet, it’s still showing version 0.8, so you might want to wait a while (at least half-an-hour to an hour) for the system to “catch up”. Again, the SVN itself has the latest version in the trunk.


    _ck_
    Participant

    @_ck_

    I’ve noticed the plugin browser is usually on a 30 minute delay or so after svn updates.

    I bet it runs on a cron job or something like that.

    Actually I had the same problem with the prior release, I just thought it was me.


    LMD
    Participant

    @louisedade

    Just to confirm, version 0.8.1 is definitely now available to download — but the same “missing files” problem is still happening, so until it’s fixed, you’ll need to download the contents of the additional-files/my-templates/ and additional-files/avatars/* folders via the svn.

    (* if you’ve already got a copy of the plugin, don’t bother to download the additional-files/avatars/content, it hasn’t changed.)

    My default avatars don’t seem to be working anymore (just upgraded from .3) I get image html in my posts that looks something like this:

    <img src=”http://forums.lrcd.com/avatars/&#8221; width=”maasman” height=”” alt=”” />

    Shouldn’t it be displaying some default.png action? Maybe I missed a file, I’ll try reinstalling.

    Also, The missing files in the ZIP took a while to figure out, you might want to add something to the readme about that if they can’t fix the bug soon.


    LMD
    Participant

    @louisedade

    Sounds like you hit the same problem as fel, sorry about that.

    I’ll try and get that update out today!

    As for the other issue, yeah, I’ll add a note – although I’ve had an idea about a way to circumvent the problem (a theory, anyway).


    LMD
    Participant

    @louisedade

    I have a strange request. Something on the lines thats similiar to the digg profile page. Is it possible that someone could help me accomplish the following:

    When the file gets uploaded it generates 2 images.

    1) The full version

    2) A smaller 25px25px mini version with the filename small_$user_identity.jpg

    I would be very grateful if someone can help me with this ^^


    LMD
    Participant

    @louisedade

    You mean you want a thumbnail version? That is certainly possible, but it won’t happen for a while – if you don’t mind waiting, I can look at it next weekend.

    Thank you louisedade! I really appreciate this! :D

    Hey louisedade :) Not that I wanna bother you but its a week since I wrote my reply to your post.

    Are you still interested in helping out?


    LMD
    Participant

    @louisedade

    Hi,

    Yeah… sorry I didn’t get a chance to look at it last weekend. I’m looking at it now though.


    LMD
    Participant

    @louisedade

    Thumbnails are now an undocumented feature in version 0.8.3.

    It’s undocumented because I think it ought to be road tested first. To use thumbnails you have to enable the feature in the plugin file itself, it is not configurable in the admin options page.

    1. Open up bb-avatar-upload.php and in the configuration settings class, scroll down to the following section:

    // Use a thumbnail image (hidden feature for now). 1 = yes / 0 = no (default)
    $this->use_thumbnail = 0;
    $this->thumb_width = 25;
    $this->thumb_height = 25;

    Set $this->use_thumbnail to 1 to enable and change the dimensions if desired.

    When enabled, whenever a user uploads an avatar a smaller copy is created with the prefix ‘thumb.‘ So the avatar username.jpg will have a thumbnail called thumb.username.jpg (the file type changes with the avatar file type, so PNG avatars produce PNG thumbnails etc).

    2. You can access the thumbnail image with the following function call:

    echo avatarupload_displaythumb($user->ID);

    An image tag is returned with the class name avatar_thumb.

    <img src="thumb.username.jpg" width="25" height="25" alt="Username" class="avatar_thumb">

    I think that covers everything, let me know if you have any problems.


    Nola1974
    Participant

    @nolageek

    How about getting this to work with MonsterIDs as well as identicons?

    Thumbnails working good so far. Maybe when you ‘officially’ add thumbnail support to the admin page you could add an option that would go through the /forums/avatars/ directory and create thumbnails for avatars that don’t have thumbnails (ie. avatars that were uploaded prior to the use of this thumbnail feature).

    To fix any odd problems regarding permissions, you can CHMOD it using PHP.

    Add the code above line 128 where it says "$success_message = "Your avatar has been uploaded.";

    chmod("/PATH/TO/FORUMS/".$config->avatar_dir . $user_filename, 0666);


    _ck_
    Participant

    @_ck_

    Another fix for another caching bug:

    The query below is never cached – hence if the avatar is for a user other than the current one and is shown multiple times on a page, it causes a query each time since it does not pass through the bbpress caching mechanism.

    (around line 117)

    $bb_query = "SELECT meta_value FROM $bbdb->usermeta WHERE meta_key='avatar_file' AND user_id='$id' LIMIT 1";
    if ( $avatar = $bbdb->get_results($bb_query) ) {

    replace with this code to properly cache and radically reduce queries on a busy topic:

    if ( $avatar = bb_get_usermeta( $id, "avatar_file")) {
    $a = explode("|", $avatar);

    note that $avatar[0]->meta_value is then simply replaced with $avatar

    This may require newer versions of bbpress (build 904+) but that was seven months ago as of my post now.

    I think I am going to whip up a little “import gravatar” feature for this.


    319
    Participant

    @noyz319

    Where can you download this plugin??? This link in the plugin repository does not work:

    https://bbpress.org/plugins/topic/avatar-upload/avatar-upload.0.8.3.zip

    It gives me a 404 File Not Found message


    Sam Bauers
    Participant

    @sambauers

    That should be fixed now.


    thierryyyyyyy
    Participant

    @thierryyyyyyy

    hi everybody.

    one user tried to upload its avatar and he always get this error : “The file is not a valid GIF, JPG/JPEG or PNG image-type.”

    He send me the .jpg, I tried to upload it for him, and I get the same error. I checked the file : it is really a jpg. I resized it with irfanview, in order to change size and weight (even if the file was already small enough). Same error.

    I solve this problem in putting the file in the avatar directory and changing the usermeta directly in the database … but I won’t do that for all my users !

    Someone has an idea ?


    chrishajer
    Participant

    @chrishajer

    Is it possible the extension was in all caps? I think the plugin expects to see one of a specific list of extensions, and they’re all lower case.

    'file_extns' => array("gif", "jpg", "jpeg", "png")

    If it wasn’t one of those extensions, I think you would get an error.


    LMD
    Participant

    @louisedade

    Hmm.. ok, it’s been a logn time since I was here, sorry about that.

    The file extension being in all caps shouldn’t be a problem, the filenames are made lower case before they are checked.

    It could be the file got corrupted or something, or isn’t a proper JPEG – what software did he use to create it?

Viewing 25 replies - 76 through 100 (of 128 total)
  • The topic ‘Plugin: Avatar Upload’ is closed to new replies.
Skip to toolbar