function _user_install_picture_field

Creates a user picture image field for the User entity.

3 calls to _user_install_picture_field()
standard_install in drupal/core/profiles/standard/standard.install
Implements hook_install().
UserPictureTest::setUp in drupal/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php
Sets up a Drupal site for running functional and integration tests.
user_update_8011 in drupal/core/modules/user/user.install
Create user picture field.

File

drupal/core/modules/user/user.install, line 973
Install, update and uninstall functions for the user module.

Code

function _user_install_picture_field(array $settings = array()) {
  $t = get_t();
  $settings += array(
    'formatter' => 'image',
    'file_directory' => 'pictures',
    'default_image' => 0,
    'image_style' => 'thumbnail',
    'max_resolution' => '85x85',
    'max_filesize' => '30 KB',
    'description' => $t('Your virtual face or picture.'),
  );
  $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,
    ),
    'storage' => array(
      'type' => 'field_sql_storage',
      'settings' => array(),
    ),
  );
  _update_7000_field_create_field($field);
  $instance = array(
    'field_name' => 'user_picture',
    'entity_type' => 'user',
    'label' => 'Picture',
    'bundle' => 'user',
    'description' => $settings['description'],
    'required' => FALSE,
    'settings' => array(
      'file_extensions' => 'png gif jpg jpeg',
      'file_directory' => $settings['file_directory'],
      'max_filesize' => $settings['max_filesize'],
      'alt_field' => 0,
      'title_field' => 0,
      'max_resolution' => $settings['max_resolution'],
      'min_resolution' => '',
      'default_image' => $settings['default_image'],
    ),
    'widget' => array(
      'module' => 'image',
      'type' => 'image_image',
      'settings' => array(
        'progress_indicator' => 'throbber',
        'preview_image_style' => 'thumbnail',
      ),
      'weight' => -1,
    ),
    'display' => array(
      'default' => array(
        'label' => 'hidden',
        'type' => $settings['formatter'],
        'settings' => array(
          'image_style' => 'thumbnail',
          'image_link' => 'content',
        ),
      ),
      'compact' => array(
        'label' => 'hidden',
        'type' => $settings['formatter'],
        'settings' => array(
          'image_style' => $settings['image_style'],
          'image_link' => 'content',
        ),
      ),
    ),
  );
  _update_7000_field_create_instance($field, $instance);
  return $field;
}