Simple BuddyPress Avatar CSS Tweaks: Rounded Corners, Shadows, Highlight Admin / Moderator

March 9, 2010  | 
8 Comments

Here are some quick CSS tips for customizing avatars in your BuddyPress theme. You can file this under the “cute things you can do with BuddyPress” category. I was inspired by a post in our forums where a user requested a way to distinguish admin / moderator avatars from general users. You don’t need to hack the core or write a plugin for it. Highlighting avatars is simple to do with a little CSS. You will add this to your child theme’s CSS file.

How to Highlight Admin Avatars:

This will add a little white border around all of your avatars site-wide with a light blue border around the admin’s avatar:

img.avatar {
	background: #ffffff;
	padding: 4px;
	border: 1px solid #ddd;
}
img.avatar.user-1-avatar {
	background: #ebf7ff;
	padding: 4px;
	border: 1px solid #ddd;
}

Note that the admin’s user number is 1. If you have other moderators whom you’d like to highlight as well, you can easily find their numbers by using Firebug to see what class BuddyPress is giving them. Or you can hover over the username in the Dashboard >> Users list and note the number that follows “user_id=” in the status bar at the bottom of your browser. Then simply add multiples like so:

img.avatar.user-1-avatar, img.avatar.user-5-avatar {
	background: #ebf7ff;
	padding: 4px;
	border: 1px solid #ddd;
}

The light blue is a slight, unobtrusive distinction for the avatars that matches the BuddyPress default theme, but you can change it to any color you like.

How to Add Rounded Corners to BuddyPress Avatars Site-wide

If you’re a fan of rounded corners, this bit of CSS will add it to your avatars site-wide. Please note that this doesn’t actually round the image but rather the corners on the border and its background.

img.avatar {
	background: #ffffff;
	padding: 4px;
	border: 1px solid #ddd;
/* Round Corners (native in Safari, Firefox and Chrome) */
	-moz-border-radius: 6px;
	-webkit-border-radius: 6px;
}

This technique does not work in IE (the bane of every developer’s existence). You’ll need to use JavaScript to accomplish this if you want it to match in IE.

How to Add a Shadow to BuddyPress Avatars with Rounded Corners

This is a cute thing you can do to your avatars to make them pop a little more:

img.avatar {
	background: #ffffff;
	padding: 4px;
	border: 1px solid #ddd;
/* Round Corners (native in Safari, Firefox and Chrome) */
	-moz-border-radius: 6px;
	-webkit-border-radius: 6px;
/* Add the Shadow */
	-moz-box-shadow: 2px 2px 2px #dddddd;
	-webkit-box-shadow: 2px 2px 2px #dddddd;
}

I hope this was helpful for those of you who want to add a little bit of customization without having to be a CSS or PHP wizard. Enjoy customizing your theme and let us know if there other tutorials that would be helpful to you. Happy theming! :)

Featured Plugin - Start your own Quora / StackOverflow / Yahoo Q&A site

It's now incredibly easy to start your own Q&A site using nothing more than WordPress - The Q&A plugin simply and brilliantly transforms any site, or page, into a perfect support or Q&A environment.
Find out more

Featured Plugin - Open an Online Store with MarketPress

Out of all the WordPress ecommerce plugins available, this has got to be the winner - easy to configure, powerful functionality, multiple gateways and more. A simply brilliant plugin!
Find out more

Featured Plugin - WordPress + Google Maps = Perfect

Simply insert google maps into posts, sidebars and pages - show directions, streetview, provide image overlays and do it all from a simple button and comprehensive widget.
Find out more

Featured Plugin - Start Your Own Powerful Membership Site

If you're thinking about starting a paid, or just private, membership site then this is truly the plugin you've been looking for. Easy to use, massively configurable and ready to go out of the box!
Find out more

Featured Plugin - Add bottom corner (or anywhere else) chat to your site

No javascript required, no third part chat engine, just fully featured chat right in your own database on your own WP sites - couldn't be easier.
Find out more

Featured Plugin - Turn any WordPress page into a fully featured wiki!

To get a wiki up and running you used to need to install Mediawiki and toil away for days configuring it... not any more! This plugin gives you *all* the functionality you want from a wiki, in WordPress!!!
Find out more

Featured Plugin - Easily integrate your WordPress site with Facebook

Would you like to add Facebook comments, registration, 'Like' buttons and autoposting to your WP site? Well, The Ultimate Facebook plugin has got that all covered!
Find out more

Featured Plugin - Every great SEO tweak you need, in one snazzy bundle

Fully integrated with the SEOMoz API, complete with automatic links, sitemaps and SEO optimization of your WordPress setup - this is the only plugin you need to help you rank your site number 1 on Google - nothing else compares.
Find out more

Featured Plugin - Host sites, get paid, just like WordPress.com

If you've ever wondered how you could offer a paid site management and hosting service, then this is the plugin for you. Offer a freemium or paid service, for any niche you like, it's powered Edublogs.org to success already!
Find out more

8 Responses to Simple BuddyPress Avatar CSS Tweaks: Rounded Corners, Shadows, Highlight Admin / Moderator

  1. Very useful tips. Especially the one to highlight avatars of admins/moderators! I was looking for it. Thanks. ;)

  2. That’s very cool and simple. I’m struggling for a way to tie the avatar’s border to a field in the buddypress profile. I think I have to edit get_avatar or maybe there is a buddypress function for get_avatar?

    This is pretty much a requirement for me to come up with and I think it would make a decent plugin. Any thoughts or other references I could check?

    I’m working on http://tkdunion.org which is for Taekwon-Do practitioners. So, a black belt should have a black border, a green belt, a green one. Further, we want to highlight 2nd, 3rd and on up to 9th degree black belts.

    Thanks for posting this! Your site is loaded with gems – lots to read here.

  3. Nice idea, Sarah. What a great little tweak!

  4. Would be great if the entire activity bit was highlighted, as well as forum posts, not just the avatar

    wink wink

  5. Arno – That’ll have to be saved for another post. ;)

  6. Pingback: Twitter Follow Limit Per Day | Confession of a Twitter Addict

  7. Thank you for this writeup. The icons look much nicer with the rounded borders and shadow!

  8. hey there, i’m having a bit of trouble with the highlight code. i had it working before but it disappeared when i upgraded my buddypress.

    i’m not a wordpress expert so maybe i’m pasting the code in the wrong place.

    any ideas or where should i be pasting it?

    it’s an awesome code by the way. and thank you for it

Click on a tab to select how you'd like to leave your comment

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=""> <strike> <strong>

Subscribe without commenting