<!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][6600] trunk: Avatars:</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><a href="http://buddypress.trac.wordpress.org/changeset/6600">6600</a></dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2012-12-10 12:52:16 +0000 (Mon, 10 Dec 2012)</dd>
</dl>
<h3>Log Message</h3>
<pre>Avatars:
* Clean up avatar code.
* When uploading a png, use the correct file extension.
* Fixes <a href="http://buddypress.trac.wordpress.org/ticket/4705">#4705</a>.
* Enqueue Jcrop styling.</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="#trunkbpxprofilebpxprofilescreensphp">trunk/bp-xprofile/bp-xprofile-screens.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 (6599 => 6600)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-avatars.php        2012-12-10 12:40:23 UTC (rev 6599)
+++ trunk/bp-core/bp-core-avatars.php        2012-12-10 12:52:16 UTC (rev 6600)
</span><span class="lines">@@ -482,25 +482,25 @@
</span><span class="cx">         require_once( ABSPATH . '/wp-admin/includes/file.php' );
</span><span class="cx">
</span><span class="cx">         $uploadErrors = array(
</span><del>-                0 => __("There is no error, the file uploaded with success", 'buddypress'),
-                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() ),
-                3 => __("The uploaded file was only partially uploaded", 'buddypress'),
-                4 => __("No file was uploaded", 'buddypress'),
-                6 => __("Missing a temporary folder", 'buddypress')
</del><ins>+                0 => __( 'The image was uploaded successfully', 'buddypress' ),
+                1 => __( 'The image exceeds the maximum allowed file size of: ', 'buddypress' ) . size_format( bp_core_avatar_original_max_filesize() ),
+                2 => __( 'The image exceeds the maximum allowed file size of: ', 'buddypress' ) . size_format( bp_core_avatar_original_max_filesize() ),
+                3 => __( 'The uploaded file was only partially uploaded.', 'buddypress' ),
+                4 => __( 'The image was not uploaded.', 'buddypress' ),
+                6 => __( 'Missing a temporary folder.', 'buddypress' )
</ins><span class="cx">         );
</span><span class="cx">
</span><del>-        if ( !bp_core_check_avatar_upload( $file ) ) {
</del><ins>+        if ( ! bp_core_check_avatar_upload( $file ) ) {
</ins><span class="cx">                 bp_core_add_message( sprintf( __( 'Your upload failed, please try again. Error was: %s', 'buddypress' ), $uploadErrors[$file['file']['error']] ), 'error' );
</span><span class="cx">                 return false;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if ( !bp_core_check_avatar_size( $file ) ) {
-                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' );
</del><ins>+        if ( ! bp_core_check_avatar_size( $file ) ) {
+                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><del>-        if ( !bp_core_check_avatar_type( $file ) ) {
</del><ins>+        if ( ! bp_core_check_avatar_type( $file ) ) {
</ins><span class="cx">                 bp_core_add_message( __( 'Please upload only JPG, GIF or PNG photos.', 'buddypress' ), 'error' );
</span><span class="cx">                 return false;
</span><span class="cx">         }
</span><span class="lines">@@ -530,17 +530,19 @@
</span><span class="cx">                         $editor->set_quality( 100 );
</span><span class="cx">
</span><span class="cx">                         $resized = $editor->resize( bp_core_avatar_original_max_width(), bp_core_avatar_original_max_width(), false );
</span><del>-                        if ( ! is_wp_error( $resized ) )
</del><ins>+                        if ( ! is_wp_error( $resized ) ) {
</ins><span class="cx">                                 $thumb = $editor->save( $editor->generate_filename() );
</span><del>-                        else
</del><ins>+                        } else {
</ins><span class="cx">                                 $error = $resized;
</span><ins>+                        }
</ins><span class="cx">
</span><span class="cx">                         // Check for thumbnail creation errors
</span><del>-                        if ( false === $error && is_wp_error( $thumb ) )
</del><ins>+                        if ( false === $error && is_wp_error( $thumb ) ) {
</ins><span class="cx">                                 $error = $thumb;
</span><ins>+                        }
</ins><span class="cx">
</span><ins>+                        // Thumbnail is good so proceed
</ins><span class="cx">                         if ( false === $error ) {
</span><del>-                                // Thumbnail is good so proceed
</del><span class="cx">                                 $bp->avatar_admin->resized = $thumb;
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="lines">@@ -555,9 +557,9 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         // We only want to handle one image after resize.
</span><del>-        if ( empty( $bp->avatar_admin->resized ) )
</del><ins>+        if ( empty( $bp->avatar_admin->resized ) ) {
</ins><span class="cx">                 $bp->avatar_admin->image->dir = str_replace( bp_core_avatar_upload_path(), '', $bp->avatar_admin->original['file'] );
</span><del>-        else {
</del><ins>+        } else {
</ins><span class="cx">                 $bp->avatar_admin->image->dir = str_replace( bp_core_avatar_upload_path(), '', $bp->avatar_admin->resized['path'] );
</span><span class="cx">                 @unlink( $bp->avatar_admin->original['file'] );
</span><span class="cx">         }
</span><span class="lines">@@ -592,7 +594,7 @@
</span><span class="cx"> */
</span><span class="cx"> function bp_core_avatar_handle_crop( $args = '' ) {
</span><span class="cx">
</span><del>-        $defaults = array(
</del><ins>+        $r = wp_parse_args( $args, array(
</ins><span class="cx">                 'object' => 'user',
</span><span class="cx">                 'avatar_dir' => 'avatars',
</span><span class="cx">                 'item_id' => false,
</span><span class="lines">@@ -601,10 +603,8 @@
</span><span class="cx">                 'crop_h' => bp_core_avatar_full_height(),
</span><span class="cx">                 'crop_x' => 0,
</span><span class="cx">                 'crop_y' => 0
</span><del>-        );
</del><ins>+        ) );
</ins><span class="cx">
</span><del>-        $r = wp_parse_args( $args, $defaults );
-
</del><span class="cx">         /***
</span><span class="cx">          * You may want to hook into this filter if you want to override this function.
</span><span class="cx">          * Make sure you return false.
</span><span class="lines">@@ -614,7 +614,7 @@
</span><span class="cx">
</span><span class="cx">         extract( $r, EXTR_SKIP );
</span><span class="cx">
</span><del>-        if ( !$original_file )
</del><ins>+        if ( empty( $original_file ) )
</ins><span class="cx">                 return false;
</span><span class="cx">
</span><span class="cx">         $original_file = bp_core_avatar_upload_path() . $original_file;
</span><span class="lines">@@ -622,10 +622,11 @@
</span><span class="cx">         if ( !file_exists( $original_file ) )
</span><span class="cx">                 return false;
</span><span class="cx">
</span><del>-        if ( !$item_id )
</del><ins>+        if ( empty( $item_id ) ) {
</ins><span class="cx">                 $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', dirname( $original_file ), $item_id, $object, $avatar_dir );
</span><del>-        else
</del><ins>+        } else {
</ins><span class="cx">                 $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', bp_core_avatar_upload_path() . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
</span><ins>+        }
</ins><span class="cx">
</span><span class="cx">         if ( !file_exists( $avatar_folder_dir ) )
</span><span class="cx">                 return false;
</span><span class="lines">@@ -637,22 +638,28 @@
</span><span class="cx">         bp_core_delete_existing_avatar( array( 'object' => $object, 'avatar_path' => $avatar_folder_dir ) );
</span><span class="cx">
</span><span class="cx">         // Make sure we at least have a width and height for cropping
</span><del>-        if ( !(int) $crop_w )
</del><ins>+        if ( empty( $crop_w ) ) {
</ins><span class="cx">                 $crop_w = bp_core_avatar_full_width();
</span><ins>+        }
</ins><span class="cx">
</span><del>-        if ( !(int) $crop_h )
</del><ins>+        if ( empty( $crop_h ) ) {
</ins><span class="cx">                 $crop_h = bp_core_avatar_full_height();
</span><ins>+        }
</ins><span class="cx">
</span><ins>+        // Get the file extension
+        $data = @getimagesize( $original_file );
+        $ext = $data['mime'] == 'image/png' ? 'png' : 'jpg';
+
</ins><span class="cx">         // Set the full and thumb filenames
</span><del>-        $full_filename = wp_hash( $original_file . time() ) . '-bpfull.jpg';
-        $thumb_filename = wp_hash( $original_file . time() ) . '-bpthumb.jpg';
</del><ins>+        $full_filename = wp_hash( $original_file . time() ) . '-bpfull.' . $ext;
+        $thumb_filename = wp_hash( $original_file . time() ) . '-bpthumb.' . $ext;
</ins><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_core_avatar_full_width(), bp_core_avatar_full_height(), false, $avatar_folder_dir . '/' . $full_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 );
</ins><span class="cx">         $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 );
</span><span class="cx">
</span><span class="cx">         // Check for errors
</span><del>-        if ( ! $full_cropped || ! $thumb_cropped || is_wp_error( $full_cropped ) || is_wp_error( $thumb_cropped ) )
</del><ins>+        if ( empty( $full_cropped ) || empty( $thumb_cropped ) || is_wp_error( $full_cropped ) || is_wp_error( $thumb_cropped ) )
</ins><span class="cx">                 return false;
</span><span class="cx">
</span><span class="cx">         // Remove the original
</span><span class="lines">@@ -683,23 +690,27 @@
</span><span class="cx">                 return $avatar;
</span><span class="cx">
</span><span class="cx">         // If passed an object, assume $user->user_id
</span><del>-        if ( is_object( $user ) )
</del><ins>+        if ( is_object( $user ) ) {
</ins><span class="cx">                 $id = $user->user_id;
</span><span class="cx">
</span><span class="cx">         // If passed a number, assume it was a $user_id
</span><del>-        else if ( is_numeric( $user ) )
</del><ins>+        } else if ( is_numeric( $user ) ) {
</ins><span class="cx">                 $id = $user;
</span><span class="cx">
</span><span class="cx">         // If passed a string and that string returns a user, get the $id
</span><del>-        else if ( is_string( $user ) && ( $user_by_email = get_user_by( 'email', $user ) ) )
</del><ins>+        } elseif ( is_string( $user ) && ( $user_by_email = get_user_by( 'email', $user ) ) ) {
</ins><span class="cx">                 $id = $user_by_email->ID;
</span><ins>+        }
</ins><span class="cx">
</span><span class="cx">         // If somehow $id hasn't been assigned, return the result of get_avatar
</span><del>-        if ( empty( $id ) )
</del><ins>+        if ( empty( $id ) ) {
</ins><span class="cx">                 return !empty( $avatar ) ? $avatar : $default;
</span><ins>+        }
</ins><span class="cx">
</span><del>-        if ( !$alt )
</del><ins>+        // Image alt tag
+        if ( empty( $alt ) ) {
</ins><span class="cx">                 $alt = sprintf( __( 'Avatar of %s', 'buddypress' ), bp_core_get_user_displayname( $id ) );
</span><ins>+        }
</ins><span class="cx">
</span><span class="cx">         // Let BuddyPress handle the fetching of the avatar
</span><span class="cx">         $bp_avatar = bp_core_fetch_avatar( array( 'item_id' => $id, 'width' => $size, 'height' => $size, 'alt' => $alt ) );
</span></span></pre></div>
<a id="trunkbpcorebpcorecssjsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-cssjs.php (6599 => 6600)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-cssjs.php        2012-12-10 12:40:23 UTC (rev 6599)
+++ trunk/bp-core/bp-core-cssjs.php        2012-12-10 12:52:16 UTC (rev 6600)
</span><span class="lines">@@ -1,4 +1,5 @@
</span><span class="cx"> <?php
</span><ins>+
</ins><span class="cx"> // Exit if accessed directly
</span><span class="cx"> if ( !defined( 'ABSPATH' ) ) exit;
</span><span class="cx">
</span><span class="lines">@@ -25,6 +26,7 @@
</span><span class="cx">                         });
</span><span class="cx">                 });
</span><span class="cx">         </script>
</span><ins>+
</ins><span class="cx"> <?php
</span><span class="cx"> }
</span><span class="cx"> add_action( 'wp_head', 'bp_core_confirmation_js', 100 );
</span><span class="lines">@@ -38,6 +40,7 @@
</span><span class="cx"> * @package BuddyPress Core
</span><span class="cx"> */
</span><span class="cx"> function bp_core_add_jquery_cropper() {
</span><ins>+        wp_enqueue_style( 'jcrop' );
</ins><span class="cx">         wp_enqueue_script( 'jcrop', array( 'jquery' ) );
</span><span class="cx">         add_action( 'wp_head', 'bp_core_add_cropper_inline_js' );
</span><span class="cx">         add_action( 'wp_head', 'bp_core_add_cropper_inline_css' );
</span><span class="lines">@@ -51,21 +54,28 @@
</span><span class="cx"> * @package BuddyPress Core
</span><span class="cx"> */
</span><span class="cx"> function bp_core_add_cropper_inline_js() {
</span><del>-        global $bp;
</del><span class="cx">
</span><del>-        $image = apply_filters( 'bp_inline_cropper_image', getimagesize( bp_core_avatar_upload_path() . $bp->avatar_admin->image->dir ) );
-        $aspect_ratio = 1;
</del><ins>+        // Bail if no image was uploaded
+        $image = apply_filters( 'bp_inline_cropper_image', getimagesize( bp_core_avatar_upload_path() . buddypress()->avatar_admin->image->dir ) );
+        if ( empty( $image ) )
+                return;
</ins><span class="cx">
</span><ins>+        //
</ins><span class="cx">         $full_height = bp_core_avatar_full_height();
</span><span class="cx">         $full_width = bp_core_avatar_full_width();
</span><span class="cx">
</span><span class="cx">         // Calculate Aspect Ratio
</span><del>-        if ( $full_height && ( $full_width != $full_height ) )
</del><ins>+        if ( !empty( $full_height ) && ( $full_width != $full_height ) ) {
</ins><span class="cx">                 $aspect_ratio = $full_width / $full_height;
</span><ins>+        } else {
+                $aspect_ratio = 1;
+        }
</ins><span class="cx">
</span><del>-                $width = $image[0] / 2;
-                $height = $image[1] / 2;
-?>
</del><ins>+        // Default cropper coordinates
+        $crop_left = $image[0] / 4;
+        $crop_top = $image[1] / 4;
+        $crop_right = $image[0] - $crop_left;
+        $crop_bottom = $image[1] - $crop_top; ?>
</ins><span class="cx">
</span><span class="cx">         <script type="text/javascript">
</span><span class="cx">                 jQuery(window).load( function(){
</span><span class="lines">@@ -73,10 +83,10 @@
</span><span class="cx">                                 onChange: showPreview,
</span><span class="cx">                                 onSelect: showPreview,
</span><span class="cx">                                 onSelect: updateCoords,
</span><del>-                                aspectRatio: <?php echo $aspect_ratio ?>,
-                                setSelect: [ 50, 50, <?php echo $width ?>, <?php echo $height ?> ]
</del><ins>+                                aspectRatio: <?php echo $aspect_ratio; ?>,
+                                setSelect: [ <?php echo $crop_left; ?>, <?php echo $crop_top; ?>, <?php echo $crop_right; ?>, <?php echo $crop_bottom; ?> ]
</ins><span class="cx">                         });
</span><del>-                        updateCoords({x: 50, y: 50, w: <?php echo $width ?>, h: <?php echo $height ?>});
</del><ins>+                        updateCoords({x: <?php echo $crop_left; ?>, y: <?php echo $crop_top; ?>, w: <?php echo $crop_right; ?>, h: <?php echo $crop_bottom; ?>});
</ins><span class="cx">                 });
</span><span class="cx">
</span><span class="cx">                 function updateCoords(c) {
</span><span class="lines">@@ -88,14 +98,14 @@
</span><span class="cx">
</span><span class="cx">                 function showPreview(coords) {
</span><span class="cx">                         if ( parseInt(coords.w) > 0 ) {
</span><del>-                                var rx = <?php echo $full_width; ?> / coords.w;
-                                var ry = <?php echo $full_height; ?> / coords.h;
</del><ins>+                                var fw = <?php echo $full_width; ?>;
+                                var fh = <?php echo $full_height; ?>;
+                                var rx = fw / coords.w;
+                                var ry = fh / coords.h;
</ins><span class="cx">
</span><del>-                                jQuery('#avatar-crop-preview').css({
-                                <?php if ( $image ) : ?>
</del><ins>+                                jQuery( '#avatar-crop-preview' ).css({
</ins><span class="cx">                                         width: Math.round(rx * <?php echo $image[0]; ?>) + 'px',
</span><span class="cx">                                         height: Math.round(ry * <?php echo $image[1]; ?>) + 'px',
</span><del>-                                <?php endif; ?>
</del><span class="cx">                                         marginLeft: '-' + Math.round(rx * coords.x) + 'px',
</span><span class="cx">                                         marginTop: '-' + Math.round(ry * coords.y) + 'px'
</span><span class="cx">                                 });
</span><span class="lines">@@ -118,16 +128,11 @@
</span><span class="cx">
</span><span class="cx">         <style type="text/css">
</span><span class="cx">                 .jcrop-holder { float: left; margin: 0 20px 20px 0; text-align: left; }
</span><del>-                .jcrop-vline, .jcrop-hline { font-size: 0; position: absolute; background: white top left repeat url('<?php echo BP_PLUGIN_URL ?>/bp-core/images/Jcrop.gif'); }
-                .jcrop-vline { height: 100%; width: 1px !important; }
-                .jcrop-hline { width: 100%; height: 1px !important; }
-                .jcrop-handle { font-size: 1px; width: 7px !important; height: 7px !important; border: 1px #eee solid; background-color: #333; *width: 9px; *height: 9px; }
-                .jcrop-tracker { width: 100%; height: 100%; }
-                .custom .jcrop-vline, .custom .jcrop-hline { background: yellow; }
-                .custom .jcrop-handle { border-color: black; background-color: #C7BB00; -moz-border-radius: 3px; -webkit-border-radius: 3px; }
</del><span class="cx">                 #avatar-crop-pane { width: <?php echo bp_core_avatar_full_width() ?>px; height: <?php echo bp_core_avatar_full_height() ?>px; overflow: hidden; }
</span><span class="cx">                 #avatar-crop-submit { margin: 20px 0; }
</span><del>-                #avatar-upload-form img, #create-group-form img, #group-settings-form img { border: none !important; }
</del><ins>+                #avatar-upload-form img,
+                #create-group-form img,
+                #group-settings-form img { border: none !important; max-width: none !important; }
</ins><span class="cx">         </style>
</span><span class="cx">
</span><span class="cx"> <?php
</span></span></pre></div>
<a id="trunkbpxprofilebpxprofilescreensphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/bp-xprofile-screens.php (6599 => 6600)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/bp-xprofile-screens.php        2012-12-10 12:40:23 UTC (rev 6599)
+++ trunk/bp-xprofile/bp-xprofile-screens.php        2012-12-10 12:52:16 UTC (rev 6600)
</span><span class="lines">@@ -36,11 +36,12 @@
</span><span class="cx"> * @uses bp_core_load_template() Looks for and loads a template file within the current member theme (folder/filename)
</span><span class="cx"> */
</span><span class="cx"> function xprofile_screen_edit_profile() {
</span><del>-        global $bp;
</del><span class="cx">
</span><span class="cx">         if ( !bp_is_my_profile() && !bp_current_user_can( 'bp_moderate' ) )
</span><span class="cx">                 return false;
</span><span class="cx">
</span><ins>+        $bp = buddypress();
+
</ins><span class="cx">         // Make sure a group is set.
</span><span class="cx">         if ( !bp_action_variable( 1 ) )
</span><span class="cx">                 bp_core_redirect( trailingslashit( bp_displayed_user_domain() . $bp->profile->slug . '/edit/group/1' ) );
</span><span class="lines">@@ -104,15 +105,17 @@
</span><span class="cx">                         foreach ( (array) $posted_field_ids as $field_id ) {
</span><span class="cx">
</span><span class="cx">                                 // Certain types of fields (checkboxes, multiselects) may come through empty. Save them as an empty array so that they don't get overwritten by the default on the next edit.
</span><del>-                                if ( empty( $_POST['field_' . $field_id] ) )
</del><ins>+                                if ( empty( $_POST['field_' . $field_id] ) ) {
</ins><span class="cx">                                         $value = array();
</span><del>-                                else
</del><ins>+                                } else {
</ins><span class="cx">                                         $value = $_POST['field_' . $field_id];
</span><ins>+                                }
</ins><span class="cx">
</span><del>-                                if ( !xprofile_set_field_data( $field_id, bp_displayed_user_id(), $value, $is_required[$field_id] ) )
</del><ins>+                                if ( !xprofile_set_field_data( $field_id, bp_displayed_user_id(), $value, $is_required[$field_id] ) ) {
</ins><span class="cx">                                         $errors = true;
</span><del>-                                else
</del><ins>+                                } else {
</ins><span class="cx">                                         do_action( 'xprofile_profile_field_data_updated', $field_id, $value );
</span><ins>+                                }
</ins><span class="cx">
</span><span class="cx">                                 // Save the visibility level
</span><span class="cx">                                 $visibility_level = !empty( $_POST['field_' . $field_id . '_visibility'] ) ? $_POST['field_' . $field_id . '_visibility'] : 'public';
</span><span class="lines">@@ -122,10 +125,11 @@
</span><span class="cx">                         do_action( 'xprofile_updated_profile', bp_displayed_user_id(), $posted_field_ids, $errors );
</span><span class="cx">
</span><span class="cx">                         // Set the feedback messages
</span><del>-                        if ( !empty( $errors ) )
</del><ins>+                        if ( !empty( $errors ) ) {
</ins><span class="cx">                                 bp_core_add_message( __( 'There was a problem updating some of your profile information, please try again.', 'buddypress' ), 'error' );
</span><del>-                        else
</del><ins>+                        } else {
</ins><span class="cx">                                 bp_core_add_message( __( 'Changes saved.', 'buddypress' ) );
</span><ins>+                        }
</ins><span class="cx">
</span><span class="cx">                         // Redirect back to the edit screen to display the updates and message
</span><span class="cx">                         bp_core_redirect( trailingslashit( bp_displayed_user_domain() . $bp->profile->slug . '/edit/group/' . bp_action_variable( 1 ) ) );
</span><span class="lines">@@ -144,16 +148,19 @@
</span><span class="cx"> * @uses bp_core_load_template() Looks for and loads a template file within the current member theme (folder/filename)
</span><span class="cx"> */
</span><span class="cx"> function xprofile_screen_change_avatar() {
</span><del>-        global $bp;
</del><span class="cx">
</span><ins>+        // Bail if not the correct screen
</ins><span class="cx">         if ( !bp_is_my_profile() && !bp_current_user_can( 'bp_moderate' ) )
</span><span class="cx">                 return false;
</span><span class="cx">
</span><ins>+        // Bail if there are action variables
</ins><span class="cx">         if ( bp_action_variables() ) {
</span><span class="cx">                 bp_do_404();
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        $bp = buddypress();
+
</ins><span class="cx">         if ( ! isset( $bp->avatar_admin ) )
</span><span class="cx">                 $bp->avatar_admin = new stdClass();
</span><span class="cx">
</span><span class="lines">@@ -179,10 +186,19 @@
</span><span class="cx">                 // Check the nonce
</span><span class="cx">                 check_admin_referer( 'bp_avatar_cropstore' );
</span><span class="cx">
</span><del>-                if ( !bp_core_avatar_handle_crop( array( 'item_id' => bp_displayed_user_id(), 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h'] ) ) )
-                        bp_core_add_message( __( 'There was a problem cropping your avatar, please try uploading it again', 'buddypress' ), 'error' );
-                else {
-                        bp_core_add_message( __( 'Your new avatar was uploaded successfully!', 'buddypress' ) );
</del><ins>+                $args = array(
+                        'item_id' => bp_displayed_user_id(),
+                        'original_file' => $_POST['image_src'],
+                        'crop_x' => $_POST['x'],
+                        'crop_y' => $_POST['y'],
+                        'crop_w' => $_POST['w'],
+                        'crop_h' => $_POST['h']
+                );
+
+                if ( ! bp_core_avatar_handle_crop( $args ) ) {
+                        bp_core_add_message( __( 'There was a problem cropping your avatar.', 'buddypress' ), 'error' );
+                } else {
+                        bp_core_add_message( __( 'Your new avatar was uploaded successfully.', 'buddypress' ) );
</ins><span class="cx">                         do_action( 'xprofile_avatar_uploaded' );
</span><span class="cx">                 }
</span><span class="cx">         }
</span></span></pre>
</div>
</div>
</body>
</html>