Fix the Avatar Cropping Issue in Buddypress


Buddypress is a great option for running closed social networks in WordPress.  However, if it doesn’t perfectly fit your needs out of the box, you’ll soon realize that it has some serious shortcomings.

One of the most common issues I see posted about buddypress, that up till now had no solution, is the issue of Avatar cropping.  In buddypress, all user profile pictures must be square.  Any non-square image uploaded will be provided with a javascript-based crop tool, that allows the user to choose what square to show.  However, many images have no good square option.

Consider a text-based company logo.  It may have an aspect ratio of 3:1, but a square crop of the image would lose all meaning, and look sloppy.  You could tell users to send it to a graphic designer to get a square version created, but that is a great way to lose users.  Instead, I tackled the issue programmatically.

If you require the following script in your theme’s functions.php file, it will detect when users upload non-square profile photos, and will add padding to make them square, before displaying the crop interface.  That way, if the image must remain complete, it can simply be displayed centered in the square, with padding surrounding it.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>