bbPress

Simple, Fast, Elegant

bbPress plugin browser »

Avatar Upload (0.8.3)

Download

Version: 0.8.3

Other Versions

Last Updated: 2007-9-9

Requires bbPress Version: 0.8.2 or higher

Compatible up to: 0.8.2.1

Author Homepage »

Plugin Homepage »

Average Rating

5 stars
4 stars
3 stars
2 stars
1 star
(10)

Your Rating

Author: Louise Dade


  1. citizenkeith

    Member

    Thanks for this plugin, and also for updating it. :)

    I'd love to see a way for users to "turn off" avatars if they so choose. Something in the Preferences would be swell. :D

    Posted: 5 months ago #
  2. elitestyles

    Member

    Thanks for a great plugin!

    So i've successfully installed it but one thing which i hate is the Identicon image that is generated if clicked on, cant this be switched to the orginal default.png image? It makes more sense?

    Could someone tell me how i can change the Identicon option in the profile to default.png

    To begin with if the user signs up to the forum it automatically gives the user the default.png as an avatar. great so it he/she decides to upload their own great go into their profile and do so...

    but i hate the fact that the Identicon option in the profile generates some horrible looking image, i would prefer that all user without avatars or choosing to use the default would have the deafult.png

    ok the whole idea of the idenicon is so everyone is different but i hate the way it looks, help?

    Posted: 4 months ago #
  3. There is an option on the avatar Admin page:

    Action to take when a user has no avatar present:
    (*) Use the default avatar image
    ( ) Use an auto generated identicon

    Just make sure "use default" is selected.

    Unfortunately, anybody who already has an identicon will still have it - but you could always delete them directly from the database, or the users could upload their own avatar.

    I ought to add a "delete avatar" option for the user.

    Posted: 4 months ago #
  4. DuncanS

    Member

    Hi
    Great plugin - only problem is it's not displaying the avatars. Upload fine, no problem - images are appearing in the folder with the default.png image. Just not appearing anywhere on the forums. Is there something else I need to be doing?
    Thanks

    Posted: 4 months ago #
  5. retrospec

    Member

    Hello,
    I found that I couldn't figure out how to fix. The avatar image is about 20 pixels lower down than the top of the corresponding forum topic box and the words 'RSS feed for this topic' is partially covered by the avatar.

    Posted: 3 months ago #
  6. citizenkeith

    Member

    What I meant in my earlier post about "turning off" avatars is an option for one person to globally turn off all avatars. This would help somebody with a slow connection/machine to load pages faster. All other users wouldn't be effected.

    Thanks for the great plugin! Looks to be working well in v0.9.

    Posted: 3 months ago #
  7. I'm behind on the most current version because unfortunately I've been hacking on it, but just in case you don't have these abilities yet, I've enhanced this plugin to allow deleting of avatars entirely (very easy to impliment) and also allowing their gravatar to be converted into a locally saved avatar (not so easy ;-)

    To add delete ability:
    In the avatar-upload.php in the forum root, change at the top:

    if (!empty($_FILES['p_browse']))
    to

    if( $_POST['delete'] )
    {
    		bb_delete_usermeta( $user_id, 'avatar_file');
    		$force_db = 1;	 // force download of new avatar from database
    		$success_message = "Your avatar has been deleted.";
    }
    elseif (!empty($_FILES['p_browse']))
    {

    (note how you don't even have to delete the file, just the usermeta)
    Then in the avatar.php template for the theme you have to add something like this next to the "upload" submit button:

    <p>
    <input type="submit" name="submit" id="submit" value="<?php _e('Upload Avatar'); ?>" />
     <?php if (avatarupload_get_avatar($user->ID,1, $force_db)) { ?>
      &nbsp;
    <input type="submit" name="delete" id="delete" value="<?php _e('Delete Avatar'); ?>" />
    <?php } ?>
    </p>
    Posted: 2 months ago #
  8. Adding gravatar download support is much more tricky. And this has not really been cleaned up or tweaked but feel free to play with it. I hacked in an fsockopen routine I was developing for another routine since that works even in safe-mode (unlike fopen/copy url and curl is not available on many servers)

    In the avatar.php template in your theme add something like this in an appropriate spot:

    <h3><?php _e('Current Gravatar'); ?></h3>
    <? $grav_url = "http://www.gravatar.com/avatar.php?gravatar_id=".md5($user->user_email)."&amp;default=".urlencode($default);   ?>
    <a style="border:0;text-decoration:none;" target=_blank href="http://www.gravatar.com"><img border=0 hspace=40 src="<?php echo $grav_url; ?>"></a>
    <form method="POST" action="<?php profile_tab_link($user->ID, 'avatar'); ?>">
    <label for="usegravatar"><input type="checkbox" name="gravatar" value="1" id="usegravatar" /> <?php _e('Use your Gravatar instead?'); ?></label>
    
    <input type="submit" name="submit" id="submit" value="Use Gravatar" />
    
    </form>

    and then in avatar-upload.php in the forum root, add all this after the if( $_POST['identicon'] ) { } block part (before load the template):

    if( $_POST['gravatar'] )
    {
    	$user=bb_get_user($user_id);
    	$img=fetch_gravatar($user->user_email);
    	if (!$img['tmp_name'] || !file_exists($img['tmp_name'])) {
    		$error_message = __("An unknown error has occurred.");
    	}
       else {
    		$current_avatar = avatarupload_get_avatar($user_id, 0, 1); // for comparison later
    		$user_filename = strtolower($user->user_login).".jpg";
    		if (@copy($img['tmp_name'], BBPATH . $config->avatar_dir . $user_filename)) {		
    
    		// Compare 'new' and 'current' avatar filenames
    		if (!empty($current_avatar[0]) && $user_filename != $current_avatar[0]) {
    			// If different, delete 'current' - this will only occur when
    			// the new and current avatars have different file extensions.
    			@unlink(BBPATH . $config->avatar_dir . $current_avatar[0]);
    		}
    
    		// Add avatar to database as usermeta data (append unix time to help browser caching probs).
    		$meta_avatar = $user_filename . "?" . time() . "|" . $img_w . "|" . $img_h . "|avatar-upload";
    		bb_update_usermeta( $user_id, 'avatar_file', $meta_avatar );
    		$force_db = 1;	 // force download of new avatar from database
    		$success_message = "Your gravatar has been downloaded.";
    
    		}
    
    	   else { $error_message = __("An unknown error has occurred.");}
    	}
    }
    
    function fetch_gravatar($email) {
    $addr="www.gravatar.com";
    $port=80;
    $path="/avatar.php?gravatar_id=".md5($email);
    $user=""; $pass=""; $timeout="15";
    $agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"; 
    
    $handle = fsockopen($addr, $port, $errno, $errstr, $timeout);
    $result['tmp_name'] = tempnam("gravatarfakedir","gravatarprefix");
    $tmpfile= fopen($result['tmp_name'], "wb");           
    
            if (!$handle || !$result['tmp_name'])    {
                    $result['code']=0;
                    $result['response']="$errno $errstr";	// error
                    $result['headers']="";
                    $result['tmp_name']="";
              }
    else {
              socket_set_timeout($handle, $timeout);
               if ($path)      {$urlString = "GET $path HTTP/1.0\r\nHost: $addr\r\nConnection: Keep-Alive\r\nUser-Agent: $agent\r\n";}
               if ($user)      {$urlString .= "Authorization: Basic ".base64_encode("$user:$pass")."\r\n";}
               $urlString .= "\r\n";
    
               fputs($handle, $urlString);
               $result['response']= fgets($handle);
               $result['code']=substr($result['response'],9,3);
               $result['headers']="";
    
               if (in_array($result['code'],array("200","301","302","401")))  {    // Check the status of the link
               	 	$endHeader = false;                     // Strip initial header information
                               while ( !$endHeader && !feof($handle))       {
                                   	$test=fgets($handle);
                                   	if (!(strpos(strtolower($test),"location:")===false)) {$result['redirect']=trim(preg_replace("/location:/i","",$test));}
                                    	if ($test== "\r\n") {  $endHeader = true; } else {$result['headers'].=$test;}
                                 }
                                while (!feof($handle)) {fwrite($tmpfile, fgets($handle, 8192));}
                 }
                 }
    
      if ($handle) {fclose($handle);}
      if ($tmpfile) {fclose($tmpfile);}
      return $result;
    }
    Posted: 2 months ago #
  9. Oh and the Identicon switch does not return success/error status messages or refresh the icon properly upon success because the function cannot return the values globally. So change it to this in avatar-upload.php in the forum root.

    // Has user checked the "Use Identicon" option?
    if( $_POST['identicon'] )
    {
    	felapplyidenticon( $user_id ); // create an identicon
    	if (usingidenticon($user_id)) {
    	$force_db = 1;	 // force download of new avatar from database
    	$success_message = "Your identicon has been made.";
    	} else { $error_message = __("An unknown error has occurred.");}
    }

    and it will "magically" work properly... ;-)

    All this improvements can be seen on http://bbShowcase.org if you register and go look at your profile and play with the avatar features.

    Posted: 2 months ago #
  10. monstr

    Member

    hm the plugin did not chmod properly, so i added this. now it works fine. this is so strange.
    // strange chmod hack for file permissions by monstr
    chmod($config->avatar_dir . $user_filename, 232);]

    but somehow the avatars do not show up on topics. theres alwas the gravatar :/
    how can i fix that?

    Posted: 2 months ago #
  11. jeffwong

    Member

    I don't know what happen to my Avatar Upload plug in
    The "Avatar" tab did not appear on the user's Profile menu even I follow all the installation steps and the plug in already activated properly

    Posted: 2 months ago #
  12. jeffwong - I'm not sure this plugin is compatible with bbPress 0.9.* yet. I have the same issue.

    Posted: 2 months ago #
  13. Nevermind. I got mine to work. Here is what I forgot:

    Don't Forget!

    If you haven't already done so: upload the files in the "additional-files" directory to the following locations.

    * avatars/ - directory to the location specified on the admin page, rename if neccesary.
    * avatars/default.png - default avatar image into the directory created above.
    * avatar-upload.php - bbPress root directory.
    * my-templates/avatar.php - your my-templates/my-template-name/ (or bb-templates/kakumei/) directory.

    Read the readme.txt file that came with this plugin for more detailed instructions.

    (I got all that from the plugin page within bbPress)

    Posted: 2 months ago #
  14. I believe there is a a very big bug in function avatarupload_get_avatar

    In certain cases if the $cached part fails because there is no avatar for the requested user, essentially it then ignores the requested $id and instead just uses whatever the current $user->ID is. So if the current user or user on the profile page is say #3, but you request #7 who happens to have no avatar, it will send you #3 anyway.

    Posted: 2 months ago #
  15. I had an issue with my host where the uploaded avatars were not getting the proper file permissions.. I added the following to bbpressroot/avatar-upload.php..

    // Did we move the image to the avatar folder successfully?
            if ($img_errs == 0 && !@move_uploaded_file($img_temp, BBPATH . $config->avatar_dir . $user_filename) )
            {
                    $img_errs = 11;
            }
    
            // Did we set the permissions on the uploaded file properly?
            if ($img_errs == 0 && !@chmod($config->avatar_dir . $user_filename, 0644) )
            {
                    $img_errs = 13;
            }

    and

    case 12: // custom error code
                                    $error_message = __("The thumbnail file could not be saved to the {$config->avatar_dir} folder.");
                                    break;
                            case 13: // custom error code
                                    $error_message = __("The file permissions could not be set properly.");
                                    break;
    Posted: 2 months ago #
  16. This is a great idea. However, when uploading an avatar the default gravatar feature for bbpress takes over - there's no way to switch gravatars of. I've tried to uncheck the checkbox in my admin panel for gravatars bt everytime I click submit it rechecks itself again.

    Can anyone help?

    I've uninstalled this plugin until it works properly.

    Posted: 3 weeks ago #

RSS feed for this topic

Add a Comment

You must log in to post.

Code is Poetry.