Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

r-a-y

By: a guest on May 25th, 2010  |  syntax: PHP  |  size: 1.01 KB  |  views: 507  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. function bb_bp_avatar($avatar, $id_or_email, $size, $default, $alt) {
  3.  
  4.         $class = 'photo avatar avatar-'. $size;
  5.  
  6.         $author_id = get_post_author_id();
  7.  
  8.         $avatar_folder_url = '/wp-content/uploads/avatars/'. $author_id;
  9.  
  10.         $avatar_folder_dir = $_SERVER['DOCUMENT_ROOT'] . $avatar_folder_url;
  11.        
  12.         $avatar_name = ( 'full' == $type ) ? '-bpfull' : '-bpthumb';
  13.         $legacy_user_avatar_name = ( 'full' == $type ) ? '-avatar2' : '-avatar1';
  14.        
  15.         if ( file_exists( $avatar_folder_dir ) ) {
  16.                 if ( $av_dir = opendir( $avatar_folder_dir ) ) {
  17.                         while ( false !== ( $avatar_file = readdir($av_dir) ) ) {
  18.                                 if ( preg_match( "/{$avatar_name}/", $avatar_file ) || preg_match( "/{$legacy_user_avatar_name}/", $avatar_file ) )
  19.                                         $avatar_url = $avatar_folder_url . '/' . $avatar_file;
  20.                         }
  21.                 }
  22.                 closedir($av_dir);
  23.  
  24.                 if ( $avatar_url )
  25.                         return "<img src='{$avatar_url}' alt='{$alt}' class='{$class}' width='{$size}' height='{$size}' />";
  26.         }
  27.  
  28.         return $avatar;
  29. }
  30. add_filter( 'bb_get_avatar', 'bb_bp_avatar', 1, 5 );
  31. ?>
clone this paste RAW Paste Data