You are here

function opigno_class_app_update_7102 in Opigno Class App 7

Add default image for classes

1 call to opigno_class_app_update_7102()
opigno_class_app_install in ./opigno_class_app.install
Implements hook_install()

File

./opigno_class_app.install, line 238
Contains install instructions and logic

Code

function opigno_class_app_update_7102() {
  $type = node_type_load('class');
  if (!empty($type)) {
    $field = field_info_field('opigno_class_image');
    if (empty($field)) {
      field_create_field(array(
        'active' => 1,
        'cardinality' => 1,
        'deleted' => 0,
        'entity_types' => array(),
        'field_name' => 'opigno_class_image',
        'foreign keys' => array(
          'fid' => array(
            'columns' => array(
              'fid' => 'fid',
            ),
            'table' => 'file_managed',
          ),
        ),
        'indexes' => array(
          'fid' => array(
            0 => 'fid',
          ),
        ),
        'locked' => 0,
        'module' => 'image',
        'settings' => array(
          'default_image' => 47,
          'uri_scheme' => 'public',
        ),
        'translatable' => 0,
        'type' => 'image',
      ));
    }
    $instance = field_info_instance('node', 'opigno_class_image', 'class');
    if (empty($instance)) {
      field_create_instance(array(
        'bundle' => 'class',
        'deleted' => 0,
        'description' => '',
        'display' => array(
          'default' => array(
            'label' => 'above',
            'module' => 'image',
            'settings' => array(
              'image_link' => '',
              'image_style' => 'thumbnail',
            ),
            'type' => 'image',
            'weight' => 19,
          ),
          'teaser' => array(
            'label' => 'above',
            'settings' => array(),
            'type' => 'hidden',
            'weight' => 0,
          ),
        ),
        'entity_type' => 'node',
        'field_name' => 'opigno_class_image',
        'label' => 'Image',
        'required' => 0,
        'settings' => array(
          'alt_field' => 0,
          'default_image' => 0,
          'file_directory' => '',
          'file_extensions' => 'png gif jpg jpeg',
          'max_filesize' => '',
          'max_resolution' => '',
          'min_resolution' => '',
          'title_field' => 0,
          'user_register_form' => FALSE,
        ),
        'widget' => array(
          'active' => 1,
          'module' => 'image',
          'settings' => array(
            'preview_image_style' => 'apps_logo_small',
            'progress_indicator' => 'throbber',
          ),
          'type' => 'image_image',
          'weight' => 42,
        ),
      ));
    }
    $source_dir = drupal_get_path('module', 'opigno_class_app') . '/img';
    $filename = 'opigno_class_default.jpg';
    $source = $source_dir . '/' . $filename;
    $field = field_info_field('opigno_class_image');
    opigno_content_set_default_image($field, $filename, $source);
  }
}