You are here

function collageformatter_field_formatter_view in Collage Formatter 7

Implements hook_field_formatter_view().

File

./collageformatter.module, line 395
Main file for Collage Formatter module.

Code

function collageformatter_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {

  // If there are no images, don't do anything.
  if (empty($items)) {
    return '';
  }
  $settings = $display['settings'];
  $ids = entity_extract_ids($entity_type, $entity);
  $entity_id = $ids[0];
  $settings['gallery'] = 'collageformatter-' . $field['field_name'] . '-' . $entity_id;
  if ($settings['image_link'] == 'content') {
    $content_uri = entity_uri($entity_type, $entity);
    foreach ($items as &$item) {
      $item['content_uri'] = $content_uri['path'];
    }
  }
  $collage = collageformatter_render_collage($items, $settings);
  return $collage;
}