You are here

function node_gallery_update_7007 in Node Gallery 7

Add Node Gallery Cover file view mode.

File

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

Code

function node_gallery_update_7007(&$sandbox) {

  // First setup the file view mode.
  $bundle_settings = field_bundle_settings('file', 'image');
  $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';
  field_bundle_settings('file', 'image', $bundle_settings);
  $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']);

  // Set up the link to the gallery.
  $settings = variable_get('node_gallery_api_file_link_settings', array());
  $settings['image']['node_gallery_file_cover'] = 'gallery';
  variable_set('node_gallery_api_file_link_settings', $settings);
}