Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/26/2009 05:34:00 PM (17 years ago)
Author:
apeatling
Message:

Fixing missing slash and adding legacy group and user avatar support to fetch_avatar function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-avatars.php

    r1697 r1708  
    8989    $avatar_folder_url = apply_filters( 'bp_core_avatar_folder_url', $bp->root_domain . '/' . basename( WP_CONTENT_DIR ) . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );   
    9090    $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );   
    91 
     91   
    9292    /* If no avatars have been uploaded for this item, display a gravatar */   
    9393    if ( !file_exists( $avatar_folder_dir ) && !$no_grav ) {
     
    120120    /* Set the file names to search for to select the full size or thumbnail image. */
    121121    $avatar_name = ( 'full' == $type ) ? '-bpfull' : '-bpthumb';   
     122    $legacy_user_avatar_name = ( 'full' == $type ) ? '-avatar2' : '-avatar1';   
     123    $legacy_group_avatar_name = ( 'full' == $type ) ? '-groupavatar-full' : '-groupavatar-thumb';   
    122124   
    123125    if ( $av_dir = opendir( $avatar_folder_dir ) ) {
    124126        while ( false !== ( $avatar_file = readdir($av_dir) ) ) {
    125             if ( preg_match( "/{$avatar_name}/", $avatar_file ) )
     127            if ( preg_match( "/{$avatar_name}/", $avatar_file ) || preg_match( "/{$avatar_name}/", $legacy_user_avatar_file ) || preg_match( "/{$avatar_name}/", $legacy_group_avatar_file ) )
    126128                $avatar_url = $avatar_folder_url . '/' . $avatar_file;
    127129        }
     
    129131    closedir($av_dir);
    130132
    131     /* If no avatar is found, check for the legacy file names of '-avatar1' and '-avatar2' */
    132     if ( !$avatar_url && 'user' == $object ) {
    133         if ( $av_dir = opendir( $avatar_folder_dir ) ) {
    134             $avatar_name = ( 'full' == $type ) ? '-avatar2' : '-avatar1';   
    135        
    136             while ( false !== ( $avatar_file = readdir($av_dir) ) ) {
    137                 if ( preg_match( "/{$avatar_name}/", $avatar_file ) )
    138                     $avatar_url = $avatar_folder_url . '/' . $avatar_file;
    139             }
    140         }
    141         closedir($av_dir);
    142     }
    143 
    144     return apply_filters( 'bp_core_fetch_avatar', "<img src='{$avatar_url}' alt='{$alt}' class='{$class}'{$html_width}{$html_height} />", $params );   
     133    return apply_filters( 'bp_core_fetch_avatar', "<img src='{$avatar_url}' alt='{$alt}' id='{$css_id}' class='{$class}'{$html_width}{$html_height} />", $params );
    145134}
    146135
Note: See TracChangeset for help on using the changeset viewer.