You are here

function flexslider_fields_field_formatter_view in Flex Slider 7

Same name and namespace in other branches
  1. 7.2 flexslider_fields/flexslider_fields.module \flexslider_fields_field_formatter_view()

Implements hook_field_formatter_view().

Prepares a renderable array of images and adds the neccessary JS and CSS

File

flexslider_fields/flexslider_fields.module, line 94
Adds fields integration with FlexSlider

Code

function flexslider_fields_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  if ($field['type'] == 'media') {
    $image_items = array();
    foreach ($items as $item) {
      if ($item['file']->type == 'image') {
        $file = (array) $item['file'];
        $file += array(
          'alt' => '',
          'title' => '',
        );
        $image_items[] = $file;
      }
    }
    $items = $image_items;
  }
  $element = array();
  if (count($items) > 0) {
    $element[] = array(
      '#theme' => 'flexslider_container',
      '#items' => $items,
      '#settings' => $display['settings'],
    );
  }
  return $element;
}