Loading images into buddypress?

I'm working to convert over 10,000+ users from a legacy system to buddypress. How can I load in their profile images?

  • Panos

    Hi Candace ,

    Could you please provide some further information on this? If user already has a Profile image (gravatar) then BuddyPress should display it in the profile page. If you have set the image in a custom user meta field we can use that field in the bp_get_signup_avatar filter.

    So what we would need to know is if currently the user profile image is in a custom meta field and which field it is

    Thanks!
    Panos

  • Candace

    Hi Panos,
    I'm moving this from a completely custom system where I had the files stored on Amazon S3 so I haven't done the work to load it in yet to BuddyPress. From the old system then each of the users have a unique image on Amazon S3 already. I don't have a gravatar yet on Buddypress. What ideally I'm hoping to do is just link the unique id from S3 to the Buddypress profile but based upon what I've seen so far I don't know if that will work. (that's similar how it was done before)

    So I could setup to have the image in a custom user meta field potentially.

    Here is an example of one. http://s3.amazonaws.com/experts123.com/ProfileImages/3003d919-9dfc-49ab-ac12-8098356c0311.JPG

  • Panos

    Hi Candace ,

    I supposed you were already on WordPress and simply decided to use BuddyPress

    In this case you will first need to import your users. Not sure if you have already imported users or not, so there are three scenarios :

    1. If you haven't imported them, you will need to export them in a csv file (make sure you include the image url in the export file in some column) and then you can import them using some plugin like "Import users from CSV with meta" or some similar. You need to make sure that you import the url of profile image of each user, and import it in a meta field eg "amazon_profile_image_url".

    2. If you have already imported the user and have also imported the image url in some user meta field we can use that.

    3. If you have imported user but did not include the image url, you will need to do another export that includes the image url, and re-import so it updates user data by adding a new meta field for the image url.

    Once the meta field is set you can add the following snippet in a mu-plugin:

    add_filter( 'bp_core_avatar_default', function( $default_grav, $params ){
    
    	$user_id = bp_get_member_user_id();
    	if( bp_is_user() ){
    		$user_id = bp_displayed_user_id();
    	}
    
    	$profile_image_url = get_user_meta( $user_id, 'amazon_profile_image_url', true );
    
    	return $profile_image_url != '' ? $profile_image_url : $default_grav;
    
    }, 10, 2 );

    In the example above I used amazon_profile_image_url as meta field name, but you can replace accordingly, depending on how it has been set while importing.

    Hope this helps!