You are here

function cms_portfolio_field_formatter_view in Glazed CMS Portfolio 7

Implementation of hook_field_formatter_view().

Parameters

$entity_type:

$entity:

$field:

$instance:

$langcode:

$items:

$display:

Return value

array

File

./cms_portfolio.module, line 199

Code

function cms_portfolio_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $settings = $display['settings'];
  $images = array();
  $element = array();
  $path = drupal_get_path('module', 'cms_portfolio');
  drupal_add_css($path . '/vendor/zurb_twentytwenty/twentytwenty.css', array(
    'scope' => 'footer',
    'weight' => 110,
  ));
  drupal_add_js($path . '/vendor/zurb_twentytwenty/jquery.event.move.js', array(
    'scope' => 'footer',
    'weight' => 100,
  ));
  drupal_add_js($path . '/vendor/zurb_twentytwenty/jquery.twentytwenty.js', array(
    'scope' => 'footer',
    'weight' => 110,
  ));
  drupal_add_js(array(
    'zurbTwentytwenty' => $settings,
  ), 'setting');
  if (count($items)) {
    foreach ($items as $item) {
      $item['path'] = $item['uri'];
      if (isset($settings['image_style']) && drupal_strlen($settings['image_style'])) {
        $item['style_name'] = $settings['image_style'];
        $images[] = theme('image_style', $item);
      }
      else {
        $images[] = theme('image', $item);
      }
    }
    $element[] = array(
      '#theme' => 'image_compare',
      '#items' => $items,
      '#images' => $images,
      '#options' => array(
        'image_style' => $settings['image_style'],
        'default_offset_pct' => $settings['default_offset_pct'],
      ),
      '#entity' => $entity,
    );
  }
  return $element;
}