<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][4632] trunk: Introduces wrapper functions for avatar-related constants.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd>4632</dd>
<dt>Author</dt> <dd>boonebgorges</dd>
<dt>Date</dt> <dd>2011-07-09 21:45:45 +0000 (Sat, 09 Jul 2011)</dd>
</dl>
<h3>Log Message</h3>
<pre>Introduces wrapper functions for avatar-related constants. Also moves avatar settings into bp global so that they are more easily configurable. See #3314</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcorebpcoreavatarsphp">trunk/bp-core/bp-core-avatars.php</a></li>
<li><a href="#trunkbpcorebpcorecssjsphp">trunk/bp-core/bp-core-cssjs.php</a></li>
<li><a href="#trunkbpgroupsbpgroupsfunctionsphp">trunk/bp-groups/bp-groups-functions.php</a></li>
<li><a href="#trunkbpmembersbpmemberssignupphp">trunk/bp-members/bp-members-signup.php</a></li>
<li><a href="#trunkbpmembersbpmemberstemplatephp">trunk/bp-members/bp-members-template.php</a></li>
<li><a href="#trunkbpthemesbpdefaultactivityentryphp">trunk/bp-themes/bp-default/activity/entry.php</a></li>
<li><a href="#trunkbpthemesbpdefaultactivitypostformphp">trunk/bp-themes/bp-default/activity/post-form.php</a></li>
<li><a href="#trunkbpxprofilebpxprofilefunctionsphp">trunk/bp-xprofile/bp-xprofile-functions.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpcorebpcoreavatarsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-avatars.php (4631 => 4632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-avatars.php        2011-07-09 19:24:36 UTC (rev 4631)
+++ trunk/bp-core/bp-core-avatars.php        2011-07-09 21:45:45 UTC (rev 4632)
</span><span class="lines">@@ -11,13 +11,7 @@
</span><span class="cx"> */
</span><span class="cx"> function bp_core_set_avatar_constants() {
</span><span class="cx">         global $bp;
</span><del>-
-        if ( !defined( 'BP_AVATAR_UPLOAD_PATH' ) )
-                define( 'BP_AVATAR_UPLOAD_PATH', bp_core_avatar_upload_path() );
-
-        if ( !defined( 'BP_AVATAR_URL' ) )
-                define( 'BP_AVATAR_URL', bp_core_avatar_url() );
-
</del><ins>+        
</ins><span class="cx">         if ( !defined( 'BP_AVATAR_THUMB_WIDTH' ) )
</span><span class="cx">                 define( 'BP_AVATAR_THUMB_WIDTH', 50 );
</span><span class="cx">
</span><span class="lines">@@ -48,6 +42,31 @@
</span><span class="cx"> }
</span><span class="cx"> add_action( 'bp_init', 'bp_core_set_avatar_constants', 3 );
</span><span class="cx">
</span><ins>+function bp_core_set_avatar_globals() {
+        global $bp;
+        
+        // Dimensions
+        $bp->avatar->thumb->width          = BP_AVATAR_THUMB_WIDTH;
+        $bp->avatar->thumb->height          = BP_AVATAR_THUMB_HEIGHT;
+        $bp->avatar->full->width          = BP_AVATAR_FULL_WIDTH;
+        $bp->avatar->full->height          = BP_AVATAR_FULL_HEIGHT;
+        
+        // Upload maximums
+        $bp->avatar->original_max_width = BP_AVATAR_ORIGINAL_MAX_WIDTH;
+        $bp->avatar->original_max_filesize = BP_AVATAR_ORIGINAL_MAX_FILESIZE;
+        
+        // Defaults
+        $bp->avatar->thumb->default          = BP_AVATAR_DEFAULT_THUMB;
+        $bp->avatar->full->default          = BP_AVATAR_DEFAULT;
+        
+        // These have to be set on page load in order to avoid infinite filter loops at runtime
+        $bp->avatar->upload_path         = bp_core_avatar_upload_path();
+        $bp->avatar->url                  = bp_core_avatar_url();
+        
+        do_action( 'bp_core_set_avatar_globals' );
+}
+add_action( 'bp_setup_globals', 'bp_core_set_avatar_globals' );
+
</ins><span class="cx"> /**
</span><span class="cx"> * bp_core_fetch_avatar()
</span><span class="cx"> *
</span><span class="lines">@@ -148,17 +167,17 @@
</span><span class="cx">         if ( $width )
</span><span class="cx">                 $html_width = " width='{$width}'";
</span><span class="cx">         else
</span><del>-                $html_width = ( 'thumb' == $type ) ? ' width="' . BP_AVATAR_THUMB_WIDTH . '"' : ' width="' . BP_AVATAR_FULL_WIDTH . '"';
</del><ins>+                $html_width = ( 'thumb' == $type ) ? ' width="' . bp_core_avatar_thumb_width() . '"' : ' width="' . bp_core_avatar_full_width() . '"';
</ins><span class="cx">
</span><span class="cx">         // Set avatar height
</span><span class="cx">         if ( $height )
</span><span class="cx">                 $html_height = " height='{$height}'";
</span><span class="cx">         else
</span><del>-                $html_height = ( 'thumb' == $type ) ? ' height="' . BP_AVATAR_THUMB_HEIGHT . '"' : ' height="' . BP_AVATAR_FULL_HEIGHT . '"';
</del><ins>+                $html_height = ( 'thumb' == $type ) ? ' height="' . bp_core_avatar_thumb_height() . '"' : ' height="' . bp_core_avatar_full_height() . '"';
</ins><span class="cx">
</span><span class="cx">         // Set avatar URL and DIR based on prepopulated constants
</span><del>-        $avatar_folder_url = apply_filters( 'bp_core_avatar_folder_url', BP_AVATAR_URL . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
-        $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', BP_AVATAR_UPLOAD_PATH . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
</del><ins>+        $avatar_folder_url = apply_filters( 'bp_core_avatar_folder_url', bp_core_avatar_url() . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
+        $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', bp_core_avatar_upload_path() . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
</ins><span class="cx">
</span><span class="cx">         /****
</span><span class="cx">          * Look for uploaded avatar first. Use it if it exists.
</span><span class="lines">@@ -236,15 +255,15 @@
</span><span class="cx">                 if ( $width )
</span><span class="cx">                         $grav_size = $width;
</span><span class="cx">                 else if ( 'full' == $type )
</span><del>-                        $grav_size = BP_AVATAR_FULL_WIDTH;
</del><ins>+                        $grav_size = bp_core_avatar_full_width();
</ins><span class="cx">                 else if ( 'thumb' == $type )
</span><del>-                        $grav_size = BP_AVATAR_THUMB_WIDTH;
</del><ins>+                        $grav_size = bp_core_avatar_thumb_width();
</ins><span class="cx">
</span><span class="cx">                 // Set gravatar type
</span><span class="cx">                 if ( empty( $bp->grav_default->{$object} ) )
</span><span class="cx">                         $default_grav = 'wavatar';
</span><span class="cx">                 else if ( 'mystery' == $bp->grav_default->{$object} )
</span><del>-                        $default_grav = apply_filters( 'bp_core_mysteryman_src', BP_AVATAR_DEFAULT, $grav_size );
</del><ins>+                        $default_grav = apply_filters( 'bp_core_mysteryman_src', bp_core_avatar_default(), $grav_size );
</ins><span class="cx">                 else
</span><span class="cx">                         $default_grav = $bp->grav_default->{$object};
</span><span class="cx">
</span><span class="lines">@@ -328,7 +347,7 @@
</span><span class="cx">                 if ( !$avatar_dir ) return false;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', BP_AVATAR_UPLOAD_PATH . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
</del><ins>+        $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', bp_core_avatar_upload_path() . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
</ins><span class="cx">
</span><span class="cx">         if ( !file_exists( $avatar_folder_dir ) )
</span><span class="cx">                 return false;
</span><span class="lines">@@ -377,8 +396,8 @@
</span><span class="cx">
</span><span class="cx">         $uploadErrors = array(
</span><span class="cx">                 0 => __("There is no error, the file uploaded with success", 'buddypress'),
</span><del>-                1 => __("Your image was bigger than the maximum allowed file size of: ", 'buddypress') . size_format(BP_AVATAR_ORIGINAL_MAX_FILESIZE),
-                2 => __("Your image was bigger than the maximum allowed file size of: ", 'buddypress') . size_format(BP_AVATAR_ORIGINAL_MAX_FILESIZE),
</del><ins>+                1 => __("Your image was bigger than the maximum allowed file size of: ", 'buddypress') . size_format( bp_core_avatar_original_max_filesize() ),
+                2 => __("Your image was bigger than the maximum allowed file size of: ", 'buddypress') . size_format( bp_core_avatar_original_max_filesize() ),
</ins><span class="cx">                 3 => __("The uploaded file was only partially uploaded", 'buddypress'),
</span><span class="cx">                 4 => __("No file was uploaded", 'buddypress'),
</span><span class="cx">                 6 => __("Missing a temporary folder", 'buddypress')
</span><span class="lines">@@ -390,7 +409,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if ( !bp_core_check_avatar_size( $file ) ) {
</span><del>-                bp_core_add_message( sprintf( __( 'The file you uploaded is too big. Please upload a file under %s', 'buddypress'), size_format(BP_AVATAR_ORIGINAL_MAX_FILESIZE) ), 'error' );
</del><ins>+                bp_core_add_message( sprintf( __( 'The file you uploaded is too big. Please upload a file under %s', 'buddypress'), size_format( bp_core_avatar_original_max_filesize() ) ), 'error' );
</ins><span class="cx">                 return false;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -414,8 +433,8 @@
</span><span class="cx">         $size = @getimagesize( $bp->avatar_admin->original['file'] );
</span><span class="cx">
</span><span class="cx">         // Check image size and shrink if too large
</span><del>-        if ( $size[0] > BP_AVATAR_ORIGINAL_MAX_WIDTH ) {
-                $thumb = wp_create_thumbnail( $bp->avatar_admin->original['file'], BP_AVATAR_ORIGINAL_MAX_WIDTH );
</del><ins>+        if ( $size[0] > bp_core_avatar_original_max_width() ) {
+                $thumb = wp_create_thumbnail( $bp->avatar_admin->original['file'], bp_core_avatar_original_max_width() );
</ins><span class="cx">
</span><span class="cx">                 // Check for thumbnail creation errors
</span><span class="cx">                 if ( is_wp_error( $thumb ) ) {
</span><span class="lines">@@ -429,9 +448,9 @@
</span><span class="cx">
</span><span class="cx">         // We only want to handle one image after resize.
</span><span class="cx">         if ( empty( $bp->avatar_admin->resized ) )
</span><del>-                $bp->avatar_admin->image->dir = str_replace( BP_AVATAR_UPLOAD_PATH, '', $bp->avatar_admin->original['file'] );
</del><ins>+                $bp->avatar_admin->image->dir = str_replace( bp_core_avatar_upload_path(), '', $bp->avatar_admin->original['file'] );
</ins><span class="cx">         else {
</span><del>-                $bp->avatar_admin->image->dir = str_replace( BP_AVATAR_UPLOAD_PATH, '', $bp->avatar_admin->resized );
</del><ins>+                $bp->avatar_admin->image->dir = str_replace( bp_core_avatar_upload_path(), '', $bp->avatar_admin->resized );
</ins><span class="cx">                 @unlink( $bp->avatar_admin->original['file'] );
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -442,7 +461,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         // Set the url value for the image
</span><del>-        $bp->avatar_admin->image->url = BP_AVATAR_URL . $bp->avatar_admin->image->dir;
</del><ins>+        $bp->avatar_admin->image->url = bp_core_avatar_url() . $bp->avatar_admin->image->dir;
</ins><span class="cx">
</span><span class="cx">         return true;
</span><span class="cx"> }
</span><span class="lines">@@ -472,8 +491,8 @@
</span><span class="cx">                 'avatar_dir' => 'avatars',
</span><span class="cx">                 'item_id' => false,
</span><span class="cx">                 'original_file' => false,
</span><del>-                'crop_w' => BP_AVATAR_FULL_WIDTH,
-                'crop_h' => BP_AVATAR_FULL_HEIGHT,
</del><ins>+                'crop_w' => bp_core_avatar_full_width(),
+                'crop_h' => bp_core_avatar_full_height(),
</ins><span class="cx">                 'crop_x' => 0,
</span><span class="cx">                 'crop_y' => 0
</span><span class="cx">         );
</span><span class="lines">@@ -492,7 +511,7 @@
</span><span class="cx">         if ( !$original_file )
</span><span class="cx">                 return false;
</span><span class="cx">
</span><del>-        $original_file = BP_AVATAR_UPLOAD_PATH . $original_file;
</del><ins>+        $original_file = bp_core_avatar_upload_path() . $original_file;
</ins><span class="cx">
</span><span class="cx">         if ( !file_exists( $original_file ) )
</span><span class="cx">                 return false;
</span><span class="lines">@@ -500,7 +519,7 @@
</span><span class="cx">         if ( !$item_id )
</span><span class="cx">                 $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', dirname( $original_file ), $item_id, $object, $avatar_dir );
</span><span class="cx">         else
</span><del>-                $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', BP_AVATAR_UPLOAD_PATH . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
</del><ins>+                $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', bp_core_avatar_upload_path() . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
</ins><span class="cx">
</span><span class="cx">         if ( !file_exists( $avatar_folder_dir ) )
</span><span class="cx">                 return false;
</span><span class="lines">@@ -523,8 +542,8 @@
</span><span class="cx">         $thumb_filename = wp_hash( $original_file . time() ) . '-bpthumb.jpg';
</span><span class="cx">
</span><span class="cx">         // Crop the image
</span><del>-        $full_cropped = wp_crop_image( $original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, BP_AVATAR_FULL_WIDTH, BP_AVATAR_FULL_HEIGHT, false, $avatar_folder_dir . '/' . $full_filename );
-        $thumb_cropped = wp_crop_image( $original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, BP_AVATAR_THUMB_WIDTH, BP_AVATAR_THUMB_HEIGHT, false, $avatar_folder_dir . '/' . $thumb_filename );
</del><ins>+        $full_cropped = wp_crop_image( $original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, bp_core_avatar_full_width(), bp_core_avatar_full_height(), false, $avatar_folder_dir . '/' . $full_filename );
+        $thumb_cropped = wp_crop_image( $original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, bp_core_avatar_thumb_width(), bp_core_avatar_thumb_height(), false, $avatar_folder_dir . '/' . $thumb_filename );
</ins><span class="cx">
</span><span class="cx">         // Remove the original
</span><span class="cx">         @unlink( $original_file );
</span><span class="lines">@@ -600,7 +619,7 @@
</span><span class="cx"> * @return bool
</span><span class="cx"> */
</span><span class="cx"> function bp_core_check_avatar_size( $file ) {
</span><del>-        if ( $file['file']['size'] > BP_AVATAR_ORIGINAL_MAX_FILESIZE )
</del><ins>+        if ( $file['file']['size'] > bp_core_avatar_original_max_filesize() )
</ins><span class="cx">                 return false;
</span><span class="cx">
</span><span class="cx">         return true;
</span><span class="lines">@@ -630,21 +649,36 @@
</span><span class="cx"> * @return string Absolute path to WP upload directory
</span><span class="cx"> */
</span><span class="cx"> function bp_core_avatar_upload_path() {
</span><del>-        // Get upload directory information from current site
-        $upload_dir = wp_upload_dir();
-
-        // Directory does not exist and cannot be created
-        if ( !empty( $upload_dir['error'] ) ) {
-                $basedir = '';
-
</del><ins>+        global $bp;
+        
+        // See if the value has already been calculated and stashed in the $bp global
+        if ( isset( $bp->avatar->upload_path ) ) {
+                $basedir = $bp->avatar->upload_path;
</ins><span class="cx">         } else {
</span><del>-                $basedir = $upload_dir['basedir'];
-
-                // If multisite, and current blog does not match root blog, make adjustments
-                if ( is_multisite() && bp_get_root_blog_id() != get_current_blog_id() )
-                        $basedir = get_blog_option( bp_get_root_blog_id(), 'upload_path' );
</del><ins>+                // If this value has been set in a constant, just use that
+                if ( defined( 'BP_AVATAR_UPLOAD_PATH' ) ) {
+                        $basedir = BP_AVATAR_UPLOAD_PATH;
+                } else {
+                        // Get upload directory information from current site
+                        $upload_dir = wp_upload_dir();
+                
+                        // Directory does not exist and cannot be created
+                        if ( !empty( $upload_dir['error'] ) ) {
+                                $basedir = '';
+                
+                        } else {
+                                $basedir = $upload_dir['basedir'];
+                
+                                // If multisite, and current blog does not match root blog, make adjustments
+                                if ( is_multisite() && bp_get_root_blog_id() != get_current_blog_id() )
+                                        $basedir = get_blog_option( bp_get_root_blog_id(), 'upload_path' );
+                        }
+                }
+                
+                // Stash in $bp for later use
+                $bp->avatar->upload_path = $basedir;
</ins><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         return apply_filters( 'bp_core_avatar_upload_path', $basedir );
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -657,21 +691,160 @@
</span><span class="cx"> * @return string Full URL to current upload location
</span><span class="cx"> */
</span><span class="cx"> function bp_core_avatar_url() {
</span><del>-        // Get upload directory information from current site
-        $upload_dir = wp_upload_dir();
-
-        // Directory does not exist and cannot be created
-        if ( !empty( $upload_dir['error'] ) ) {
-                $baseurl = '';
-
</del><ins>+        global $bp;
+        
+        // See if the value has already been calculated and stashed in the $bp global
+        if ( isset( $bp->avatar->url ) ) {
+                $baseurl = $bp->avatar->url;
</ins><span class="cx">         } else {
</span><del>-                $baseurl = $upload_dir['baseurl'];
-
-                // If multisite, and current blog does not match root blog, make adjustments
-                if ( is_multisite() && bp_get_root_blog_id() != get_current_blog_id() )
-                        $baseurl = trailingslashit( get_blog_option( bp_get_root_blog_id(), 'home' ) ) . get_blog_option( bp_get_root_blog_id(), 'upload_path' );
</del><ins>+                // If this value has been set in a constant, just use that
+                if ( defined( 'BP_AVATAR_URL' ) ) {
+                        $baseurl = BP_AVATAR_URL;
+                } else {
+                        // Get upload directory information from current site
+                        $upload_dir = wp_upload_dir();
+                
+                        // Directory does not exist and cannot be created
+                        if ( !empty( $upload_dir['error'] ) ) {
+                                $baseurl = '';
+                
+                        } else {
+                                $baseurl = $upload_dir['baseurl'];
+                
+                                // If multisite, and current blog does not match root blog, make adjustments
+                                if ( is_multisite() && bp_get_root_blog_id() != get_current_blog_id() )
+                                        $baseurl = trailingslashit( get_blog_option( bp_get_root_blog_id(), 'home' ) ) . get_blog_option( bp_get_root_blog_id(), 'upload_path' );
+                        }
+                }
+                
+                // Stash in $bp for later use
+                $bp->avatar->url = $baseurl;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         return apply_filters( 'bp_core_avatar_url', $baseurl );
</span><span class="cx"> }
</span><ins>+
+/**
+ * Utility function for fetching an avatar dimension setting
+ *
+ * @package BuddyPress
+ * @since 1.3
+ *
+ * @param str $type 'thumb' for thumbs, otherwise full
+ * @param str $h_or_w 'height' for height, otherwise width
+ * @return int $dim The dimension
+ */
+function bp_core_avatar_dimension( $type = 'thumb', $h_or_w = 'height' ) {
+        global $bp;
+        
+        $dim = isset( $bp->avatar->{$type}->{$h_or_w} ) ? (int)$bp->avatar->{$type}->{$h_or_w} : false;
+        
+        return apply_filters( 'bp_core_avatar_dimension', $dim, $type, $h_or_w );
+}
+
+/**
+ * Get the avatar thumb width setting
+ *
+ * @package BuddyPress
+ * @since 1.3
+ *
+ * @return int The thumb width
+ */
+function bp_core_avatar_thumb_width() {
+        return apply_filters( 'bp_core_avatar_thumb_width', bp_core_avatar_dimension( 'thumb', 'width' ) );
+}
+
+/**
+ * Get the avatar thumb height setting
+ *
+ * @package BuddyPress
+ * @since 1.3
+ *
+ * @return int The thumb height
+ */
+function bp_core_avatar_thumb_height() {
+        return apply_filters( 'bp_core_avatar_thumb_height', bp_core_avatar_dimension( 'thumb', 'height' ) );
+}
+
+/**
+ * Get the avatar full width setting
+ *
+ * @package BuddyPress
+ * @since 1.3
+ *
+ * @return int The full width
+ */
+function bp_core_avatar_full_width() {
+        return apply_filters( 'bp_core_avatar_full_width', bp_core_avatar_dimension( 'full', 'width' ) );
+}
+
+/**
+ * Get the avatar full height setting
+ *
+ * @package BuddyPress
+ * @since 1.3
+ *
+ * @return int The full height
+ */
+function bp_core_avatar_full_height() {
+        return apply_filters( 'bp_core_avatar_full_height', bp_core_avatar_dimension( 'full', 'height' ) );
+}
+
+/**
+ * Get the max width for original avatar uploads
+ *
+ * @package BuddyPress
+ * @since 1.3
+ *
+ * @return int The width
+ */
+function bp_core_avatar_original_max_width() {
+        global $bp;
+        
+        return apply_filters( 'bp_core_avatar_original_max_width', (int)$bp->avatar->original_max_width );
+}
+
+/**
+ * Get the max filesize for original avatar uploads
+ *
+ * @package BuddyPress
+ * @since 1.3
+ *
+ * @return int The filesize
+ */
+function bp_core_avatar_original_max_filesize() {
+        global $bp;
+        
+        return apply_filters( 'bp_core_avatar_original_max_filesize', (int)$bp->avatar->original_max_filesize );
+}
+
+/**
+ * Get the default avatar
+ *
+ * @package BuddyPress
+ * @since 1.3
+ *
+ * @return int The URL of the default avatar
+ */
+function bp_core_avatar_default() {
+        global $bp;
+        
+        return apply_filters( 'bp_core_avatar_default', $bp->avatar->full->default );
+}
+
+/**
+ * Get the default avatar thumb
+ *
+ * @package BuddyPress
+ * @since 1.3
+ *
+ * @return int The URL of the default avatar thumb
+ */
+function bp_core_avatar_default_thumb() {
+        global $bp;
+        
+        return apply_filters( 'bp_core_avatar_thumb', $bp->avatar->thumb->default );
+}
+
+
</ins><span class="cx"> ?>
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpcorebpcorecssjsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-cssjs.php (4631 => 4632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-cssjs.php        2011-07-09 19:24:36 UTC (rev 4631)
+++ trunk/bp-core/bp-core-cssjs.php        2011-07-09 21:45:45 UTC (rev 4632)
</span><span class="lines">@@ -72,12 +72,12 @@
</span><span class="cx"> function bp_core_add_cropper_inline_js() {
</span><span class="cx">         global $bp;
</span><span class="cx">
</span><del>-        $image = apply_filters( 'bp_inline_cropper_image', getimagesize( BP_AVATAR_UPLOAD_PATH . $bp->avatar_admin->image->dir ) );
</del><ins>+        $image = apply_filters( 'bp_inline_cropper_image', getimagesize( bp_core_avatar_upload_path() . $bp->avatar_admin->image->dir ) );
</ins><span class="cx">         $aspect_ratio = 1;
</span><span class="cx">         
</span><del>-        $full_height = (int) constant( 'BP_AVATAR_FULL_HEIGHT' );
-        $full_width = (int) constant( 'BP_AVATAR_FULL_WIDTH' );
-
</del><ins>+        $full_height = bp_core_avatar_full_height();
+        $full_width = bp_core_avatar_full_width();
+        
</ins><span class="cx">         // Calculate Aspect Ratio
</span><span class="cx">         if ( $full_height && ( $full_width != $full_height ) )
</span><span class="cx">                 $aspect_ratio = $full_width / $full_height;
</span><span class="lines">@@ -145,7 +145,7 @@
</span><span class="cx">                 .jcrop-tracker { width: 100%; height: 100%; }
</span><span class="cx">                 .custom .jcrop-vline, .custom .jcrop-hline { background: yellow; }
</span><span class="cx">                 .custom .jcrop-handle { border-color: black; background-color: #C7BB00; -moz-border-radius: 3px; -webkit-border-radius: 3px; }
</span><del>-                #avatar-crop-pane { width: <?php echo BP_AVATAR_FULL_WIDTH ?>px; height: <?php echo BP_AVATAR_FULL_HEIGHT ?>px; overflow: hidden; }
</del><ins>+                #avatar-crop-pane { width: <?php echo bp_core_avatar_full_width() ?>px; height: <?php echo bp_core_avatar_full_height() ?>px; overflow: hidden; }
</ins><span class="cx">                 #avatar-crop-submit { margin: 20px 0; }
</span><span class="cx">                 #avatar-upload-form img, #create-group-form img, #group-settings-form img { border: none !important; }
</span><span class="cx">         </style>
</span></span></pre></div>
<a id="trunkbpgroupsbpgroupsfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups/bp-groups-functions.php (4631 => 4632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups/bp-groups-functions.php        2011-07-09 19:24:36 UTC (rev 4631)
+++ trunk/bp-groups/bp-groups-functions.php        2011-07-09 21:45:45 UTC (rev 4632)
</span><span class="lines">@@ -423,13 +423,13 @@
</span><span class="cx">         if ( !$group_id )
</span><span class="cx">                 $group_id = $bp->groups->current_group->id;
</span><span class="cx">
</span><del>-        $path = BP_AVATAR_UPLOAD_PATH . '/group-avatars/' . $group_id;
</del><ins>+        $path = bp_core_avatar_upload_path() . '/group-avatars/' . $group_id;
</ins><span class="cx">         $newbdir = $path;
</span><span class="cx">
</span><span class="cx">         if ( !file_exists( $path ) )
</span><span class="cx">                 @wp_mkdir_p( $path );
</span><span class="cx">
</span><del>-        $newurl = BP_AVATAR_URL . '/group-avatars/' . $group_id;
</del><ins>+        $newurl = bp_core_avatar_url() . '/group-avatars/' . $group_id;
</ins><span class="cx">         $newburl = $newurl;
</span><span class="cx">         $newsubdir = '/group-avatars/' . $group_id;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkbpmembersbpmemberssignupphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-members/bp-members-signup.php (4631 => 4632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-members/bp-members-signup.php        2011-07-09 19:24:36 UTC (rev 4631)
+++ trunk/bp-members/bp-members-signup.php        2011-07-09 21:45:45 UTC (rev 4632)
</span><span class="lines">@@ -190,8 +190,8 @@
</span><span class="cx">
</span><span class="cx">                 // Check if the avatar folder exists. If it does, move rename it, move
</span><span class="cx">                 // it and delete the signup avatar dir
</span><del>-                if ( file_exists( BP_AVATAR_UPLOAD_PATH . '/avatars/signups/' . $hashed_key ) )
-                        @rename( BP_AVATAR_UPLOAD_PATH . '/avatars/signups/' . $hashed_key, BP_AVATAR_UPLOAD_PATH . '/avatars/' . $user );
</del><ins>+                if ( file_exists( bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key ) )
+                        @rename( bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key, bp_core_avatar_upload_path() . '/avatars/' . $user );
</ins><span class="cx">
</span><span class="cx">                 bp_core_add_message( __( 'Your account is now active!', 'buddypress' ) );
</span><span class="cx">
</span><span class="lines">@@ -549,13 +549,13 @@
</span><span class="cx">         if ( !$bp->signup->avatar_dir )
</span><span class="cx">                 return false;
</span><span class="cx">
</span><del>-        $path = BP_AVATAR_UPLOAD_PATH . '/avatars/signups/' . $bp->signup->avatar_dir;
</del><ins>+        $path = bp_core_avatar_upload_path() . '/avatars/signups/' . $bp->signup->avatar_dir;
</ins><span class="cx">         $newbdir = $path;
</span><span class="cx">
</span><span class="cx">         if ( !file_exists( $path ) )
</span><span class="cx">                 @wp_mkdir_p( $path );
</span><span class="cx">
</span><del>-        $newurl = BP_AVATAR_URL . '/avatars/signups/' . $bp->signup->avatar_dir;
</del><ins>+        $newurl = bp_core_avatar_url() . '/avatars/signups/' . $bp->signup->avatar_dir;
</ins><span class="cx">         $newburl = $newurl;
</span><span class="cx">         $newsubdir = '/avatars/signups/' . $bp->signup->avatar_dir;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkbpmembersbpmemberstemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-members/bp-members-template.php (4631 => 4632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-members/bp-members-template.php        2011-07-09 19:24:36 UTC (rev 4631)
+++ trunk/bp-members/bp-members-template.php        2011-07-09 21:45:45 UTC (rev 4632)
</span><span class="lines">@@ -994,7 +994,7 @@
</span><span class="cx">                 global $bp;
</span><span class="cx">
</span><span class="cx">                 $defaults = array(
</span><del>-                        'size' => BP_AVATAR_FULL_WIDTH,
</del><ins>+                        'size' => bp_core_avatar_full_width(),
</ins><span class="cx">                         'class' => 'avatar',
</span><span class="cx">                         'alt' => __( 'Your Avatar', 'buddypress' )
</span><span class="cx">                 );
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultactivityentryphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/activity/entry.php (4631 => 4632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/activity/entry.php        2011-07-09 19:24:36 UTC (rev 4631)
+++ trunk/bp-themes/bp-default/activity/entry.php        2011-07-09 21:45:45 UTC (rev 4632)
</span><span class="lines">@@ -81,7 +81,7 @@
</span><span class="cx">                         <?php if ( is_user_logged_in() ) : ?>
</span><span class="cx">
</span><span class="cx">                         <form action="<?php bp_activity_comment_form_action(); ?>" method="post" id="ac-form-<?php bp_activity_id(); ?>" class="ac-form"<?php bp_activity_comment_form_nojs_display(); ?>>
</span><del>-                                <div class="ac-reply-avatar"><?php bp_loggedin_user_avatar( 'width=' . BP_AVATAR_THUMB_WIDTH . '&height=' . BP_AVATAR_THUMB_HEIGHT ); ?></div>
</del><ins>+                                <div class="ac-reply-avatar"><?php bp_loggedin_user_avatar( 'width=' . bp_core_avatar_thumb_width() . '&height=' . bp_core_avatar_thumb_height() ); ?></div>
</ins><span class="cx">                                 <div class="ac-reply-content">
</span><span class="cx">                                         <div class="ac-textarea">
</span><span class="cx">                                                 <textarea id="ac-input-<?php bp_activity_id(); ?>" class="ac-input" name="ac_input_<?php bp_activity_id(); ?>"></textarea>
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultactivitypostformphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/activity/post-form.php (4631 => 4632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/activity/post-form.php        2011-07-09 19:24:36 UTC (rev 4631)
+++ trunk/bp-themes/bp-default/activity/post-form.php        2011-07-09 21:45:45 UTC (rev 4632)
</span><span class="lines">@@ -21,7 +21,7 @@
</span><span class="cx">
</span><span class="cx">         <div id="whats-new-avatar">
</span><span class="cx">                 <a href="<?php echo bp_loggedin_user_domain(); ?>">
</span><del>-                        <?php bp_loggedin_user_avatar( 'width=' . BP_AVATAR_THUMB_WIDTH . '&height=' . BP_AVATAR_THUMB_HEIGHT ); ?>
</del><ins>+                        <?php bp_loggedin_user_avatar( 'width=' . bp_core_avatar_thumb_width() . '&height=' . bp_core_avatar_thumb_height() ); ?>
</ins><span class="cx">                 </a>
</span><span class="cx">         </div>
</span><span class="cx">
</span></span></pre></div>
<a id="trunkbpxprofilebpxprofilefunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/bp-xprofile-functions.php (4631 => 4632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/bp-xprofile-functions.php        2011-07-09 19:24:36 UTC (rev 4631)
+++ trunk/bp-xprofile/bp-xprofile-functions.php        2011-07-09 21:45:45 UTC (rev 4632)
</span><span class="lines">@@ -348,13 +348,13 @@
</span><span class="cx">         if ( empty( $directory ) )
</span><span class="cx">                 $directory = 'avatars';
</span><span class="cx">
</span><del>-        $path = BP_AVATAR_UPLOAD_PATH . '/avatars/' . $user_id;
</del><ins>+        $path = bp_core_avatar_upload_path() . '/avatars/' . $user_id;
</ins><span class="cx">         $newbdir = $path;
</span><span class="cx">
</span><span class="cx">         if ( !file_exists( $path ) )
</span><span class="cx">                 @wp_mkdir_p( $path );
</span><span class="cx">
</span><del>-        $newurl = BP_AVATAR_URL . '/avatars/' . $user_id;
</del><ins>+        $newurl = bp_core_avatar_url() . '/avatars/' . $user_id;
</ins><span class="cx">         $newburl = $newurl;
</span><span class="cx">         $newsubdir = '/avatars/' . $user_id;
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>