Creates a user picture image field for the User entity.
This is only used in core's standard.install, but is kept as a separate helper function so that other install profiles can reuse it.
function user_install_picture_field() {
$t = get_t();
$field = array(
'field_name' => 'user_picture',
'module' => 'image',
'type' => 'image',
'cardinality' => 1,
'locked' => FALSE,
'indexes' => array(
'fid' => array(
'fid',
),
),
'settings' => array(
'uri_scheme' => 'public',
'default_image' => FALSE,
),
);
$field = field_create_field($field);
$instance = array(
'field_name' => 'user_picture',
'entity_type' => 'user',
'label' => 'Picture',
'bundle' => 'user',
'description' => $t('Your virtual face or picture.'),
'required' => FALSE,
'settings' => array(
'file_extensions' => 'png gif jpg jpeg',
'file_directory' => 'pictures',
'max_filesize' => '30 KB',
'alt_field' => 0,
'title_field' => 0,
'max_resolution' => '85x85',
'min_resolution' => '',
'default_image' => 0,
),
);
field_create_instance($instance);
// Assign form display settings for the 'default' view mode.
entity_get_form_display('user', 'user', 'default')
->setComponent('user_picture', array(
'type' => 'image_image',
'settings' => array(
'progress_indicator' => 'throbber',
'preview_image_style' => 'thumbnail',
),
'weight' => -1,
))
->save();
// Assign display settings for the 'default' and 'compact' view modes.
entity_get_display('user', 'user', 'default')
->setComponent('user_picture', array(
'label' => 'hidden',
'type' => 'image',
'settings' => array(
'image_style' => 'thumbnail',
'image_link' => 'content',
),
))
->save();
entity_get_display('user', 'user', 'compact')
->setComponent('user_picture', array(
'label' => 'hidden',
'type' => 'image',
'settings' => array(
'image_style' => 'thumbnail',
'image_link' => 'content',
),
))
->removeComponent('member_for')
->save();
}