You are here

function node_gallery_setup_display_modes in Node Gallery 7

Set up default display mode for the image file type.

2 calls to node_gallery_setup_display_modes()
node_gallery_install in ./node_gallery.install
Implements hook_install().
node_gallery_update_7002 in ./node_gallery.install
Migrate Node Gallery relationships to Drupal 7 relationship entities.

File

./node_gallery.install, line 29
Install, update and uninstall functions for the node_gallery module.

Code

function node_gallery_setup_display_modes($item_type = NODE_GALLERY_DEFAULT_ITEM_TYPE) {

  // First setup the file view modes.
  $bundle_settings = field_bundle_settings('file', 'image');
  $bundle_settings['view_modes']['node_gallery_file_thumbnail']['custom_settings'] = TRUE;
  $bundle_settings['view_modes']['node_gallery_file_thumbnail']['file_image']['image_style'] = 'node_gallery_thumbnail';
  $bundle_settings['view_modes']['node_gallery_file_cover']['custom_settings'] = TRUE;
  $bundle_settings['view_modes']['node_gallery_file_cover']['file_image']['image_style'] = 'node_gallery_thumbnail';
  $bundle_settings['view_modes']['node_gallery_file_display']['custom_settings'] = TRUE;
  $bundle_settings['view_modes']['node_gallery_file_display']['file_image']['image_style'] = 'node_gallery_display';
  field_bundle_settings('file', 'image', $bundle_settings);

  // Now configure the file displays.
  // Thumbnail.
  $file_displays = file_displays_load('image', 'node_gallery_file_thumbnail');
  if (empty($file_displays['image__node_gallery_file_thumbnail__file_image'])) {
    $file_displays['image__node_gallery_file_thumbnail__file_image'] = file_display_new('image', 'node_gallery_file_thumbnail', 'file_image');
  }
  $file_displays['image__node_gallery_file_thumbnail__file_image']->status = 1;
  $file_displays['image__node_gallery_file_thumbnail__file_image']->settings['image_style'] = 'node_gallery_thumbnail';
  file_display_save($file_displays['image__node_gallery_file_thumbnail__file_image']);

  // Cover.
  $file_displays = file_displays_load('image', 'node_gallery_file_cover');
  if (empty($file_displays['image__node_gallery_file_cover__file_image'])) {
    $file_displays['image__node_gallery_file_cover__file_image'] = file_display_new('image', 'node_gallery_file_cover', 'file_image');
  }
  $file_displays['image__node_gallery_file_cover__file_image']->status = 1;
  $file_displays['image__node_gallery_file_cover__file_image']->settings['image_style'] = 'node_gallery_thumbnail';
  file_display_save($file_displays['image__node_gallery_file_cover__file_image']);

  // Full display.
  $file_displays = file_displays_load('image', 'node_gallery_file_display');
  if (empty($file_displays['image__node_gallery_file_display__file_image'])) {
    $file_displays['image__node_gallery_file_display__file_image'] = file_display_new('image', 'node_gallery_file_display', 'file_image');
  }
  $file_displays['image__node_gallery_file_display__file_image']->status = 1;
  $file_displays['image__node_gallery_file_display__file_image']->settings['image_style'] = 'node_gallery_display';
  file_display_save($file_displays['image__node_gallery_file_display__file_image']);
  $settings = variable_get('node_gallery_api_file_link_settings', array());
  $settings['image']['node_gallery_file_thumbnail'] = 'gallery_item';
  $settings['image']['node_gallery_file_cover'] = 'gallery';
  variable_set('node_gallery_api_file_link_settings', $settings);

  // Setup node display modes.
  $bundle_settings = field_view_mode_settings('node', $item_type);
  $bundle_settings['extra_fields']['display']['node_gallery_navigation']['node_gallery_node_thumbnail']['visible'] = FALSE;
  $bundle_settings['extra_fields']['display']['node_gallery_navigation']['node_gallery_node_thumbnail']['weight'] = 1;
  field_bundle_settings('node', $item_type, $bundle_settings);
  variable_set('node_submitted_' . $item_type, FALSE);

  // Set up the link to the gallery and gallery item.
}