How can I assign users different profile pictures upon registration based on gender? My setup: I am on Drupal 7 but not using the default user profile pictures; instead, I have a custom image field, profile_picture, which is attached to the user profile.  When users register, they must select their gender (Male/Female/Prefer not to say).

I would like to assign a different default picture to this profile_picture field based on the value each user selects for gender.  I tried using Set a data value with Rules but I can't figure out how to get these three specific pictures (one for each gender choice) to be options.

If it helps, each user also has a role based on their gender.  I'm not committed to using Rules for this; I will accept any solution that allows me to reliably set the picture based on the value of the field in their profile.  There is no opportunity for users to change their gender so this needs only be set once.

EDIT: Users are later able to replace this with their own custom profile picture, so I need to keep this as an Image field.
A simple approach might be to retheme the gender field itself so that it displays an image based upon its value, eg, instead of displaying male, it displays an image with path sites/default/files/male.png.

In D6, this would mean copying CCK's content-field.tpl.php to your theme directory and then creating content-field-field_gender.tpl.php and jiggering things up in there, eg...

print theme('image', 'sites/default/files/' . $item['view'] . '.png')


...instead of just print $item['view'].

My quick look at D7 here suggests that copying Field's field.tpl.php to field--gender--profile.tpl.php in your theme's directory would be basic starting point there and instead of render()ing $item, doing something similar with its value.  

Then, in either version, just make sure you have three images in your files directory called male.png, female.png and unknown.png (or files based upon whatever the values of your gender field are.)

With this approach, you only have three files to deal with instead of a file uploaded and stored for each and every user.  Another side benefit is that they will be easily cached by your users' browsers.

ADDITION:

Based upon new info from comments and other answers, you could do something like this in your user-picture.tpl.php template:

if (!empty($account-&gt;field_profile_picture[LANGUAGE_NONE][0]['fid'])) {
  // Load the file
  $file = file_load($account-&gt;field_profile_picture[LANGUAGE_NONE][0]['fid']);

  // Note the style name is "profile_picture" as explained in your question,
  // not "profile_pic" which was in your original code
  echo theme('image_style', array('style_name' =&gt; 'profile_picture', 'path' =&gt; $file-&gt;uri));
} else {

  $file_path = 'sites/default/files/' . $account-&gt;field_gender[LANGUAGE_NONE][0]['value'] . '.png';
  echo theme('image_style', array('style_name' =&gt; 'profile_picture', 'path' =&gt; $file_path));

}


where the new stuff is the else .... Pardon my D6ism if sites/default/files is wrong in D7, but basically you just want a path on your system to where you've stuck male.png, female.png and unknown.png and you display them when your profile_picture field is not set.