You are here

function slick_field_formatter_view in Slick Carousel 7

Implements hook_field_formatter_view().

File

./slick.module, line 103
Slick carousel for Drupal.

Code

function slick_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $settings = $display['settings'];
  $slick = array(
    '#theme' => 'slick_carousel',
    '#options' => $settings,
  );
  switch ($field['type']) {
    case 'image':
      foreach ($items as $i => $item) {
        $slick['#items'][] = array(
          '#theme' => 'image_style',
          '#path' => $item['uri'],
          '#style_name' => $settings['slick_image_style'],
          '#attributes' => array(
            'alt' => $item['alt'],
            'title' => $item['title'],
          ),
        );
      }
      break;
    case 'field_collection':
      foreach ($items as $i => $item) {
        $field_collection_item = field_collection_item_load($item['value']);
        $slick['#items'][$i] = entity_view('field_collection_item', array(
          $field_collection_item,
        ));
      }
      break;
  }
  return $slick;
}