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 3 replies - 126 through 128 (of 128 total)
  • Hi,

    This plugin use a SQL table ?


    dangerousape
    Member

    @dangerousape

    @wilcosky and everyone else who’s asked here and on the other thread, having cracked it this afternoon with the aid of a couple of online code snippets and my limited PHP skills, here’s how to display your avatars from this plugin in WP if you have WP and bbPress integrated and sharing the same user table.

    In your sidebar, or wherever you want to have them (or a “welcome, guest” message or whatever) appear, put this code snippet…

    <?php global $user_login;
    get_currentuserinfo();

    if ($user_login == '') {
    echo('Welcome Guest');
    } else {

    $directory = '/your/DOCUMENT_ROOT/path/to/forum/avatars/';
    $flag = false;
    $ext = array( '.jpg' , '.gif' , '.png' );

    for( $i = 0; count( $ext ) > $i; $i++ )
    {
    if( file_exists( $directory . $user_login . $ext[$i] ) )
    {

    $flag = true;
    $name = $user_login . $ext[$i];
    }
    }
    if( $flag == true )
    {
    echo "<img src="http://www.yoursite.com/forum/avatars/".$name."" />";
    }
    }
    ?>

    Note that the path for $directory is your DOCUMENT_ROOT one (you can use an ‘echo’ or ‘print’ PHP command to find it if you don’t know it, google for instructions; it’s usually something like ‘/home/user/public_html/’), while the later image source path is the standard http one. If your avatar directory is somewhere other than /yoursite.com/forum/avatars/ then, obviously, you’ll need to edit accordingly.

    If you use a different set of possible image file extensions than the usual .jpg, .gif and .png trio you’ll also need to edit the $ext array (so if you don’t allow .gifs, it’d be $ext = array( '.jpg' , '.png' ) for instance).


    englishmeetup
    Member

    @englishmeetup

    Hi,

    I had error below(while I pressed Avatar button):

    Warning: Cannot modify header information – headers already sent by (output started at /home/content/83/4464383/html/wordpress-mu/forums/profile.php:4) in /home/content/83/4464383/html/wordpress-mu/forums/bb-includes/functions.bb-pluggable.php on line 232

    Pls heeeeeeelp!

    Lillian

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