[buddypress-dev] suggestion: profile avatar functions

Andy Peatling andypeatling at automattic.com
Wed May 28 19:59:02 GMT 2008


On 27-May-08, at 9:39 PM, David J. Bisset wrote:
> Any reason why we can't have a function to pull the thumbnail?
>
> function the_profile_picture_thumbnail() {
> 	global $coreuser_id;
> 	echo xprofile_get_avatar($coreuser_id, 1);
> }

No reason at all, I've added that to the template tags file and I'll  
check it in later today.

> Also I want to be able to tell if the user has uploaded an avatar so  
> I can place an "add photo/avatar" button on my template. Right now,  
> I'm doing that by created the above function and adding this to my  
> code:
>
> <?php if (the_profile_picture_thumbnail(true) ==  
> XPROFILE_DEFAULT_AVATAR) {
> <div class="addphoto">
> <div class="icon"><a href="#"><img src="<?php  
> bloginfo('stylesheet_directory'); ?>/images/buttons/add_plus.gif"  
> alt="" /></a></div>
> <div class="phrase"><a href="#">Add Photo</a></div>
> <br clear="all" />
> </div> <!-- add photo -->
> <? } ?>
>
> Is there a better way? Hopefully you can see why I would desire to  
> know if the user uploaded an avatar.

It's probably a better idea to make a 'user_has_avatar()' function, do  
the calculations in there so you can just do a:

<?php if ( !user_has_avatar() ) { ... } ?>


More information about the buddypress-dev mailing list