function zurb_twentytwenty_field_formatter_view in ZURB TwentyTwenty 7
Implementation of hook_field_formatter_view().
Parameters
$entity_type:
$entity:
$field:
$instance:
$langcode:
$items:
$display:
Return value
array
File
- ./
zurb_twentytwenty.module, line 120
Code
function zurb_twentytwenty_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$settings = $display['settings'];
$images = array();
$element = array();
$twentytwenty_path = libraries_get_path('twentytwenty');
drupal_add_css($twentytwenty_path . '/css/twentytwenty.css', array(
'scope' => 'footer',
'weight' => 110,
));
drupal_add_js($twentytwenty_path . '/js/jquery.event.move.js', array(
'scope' => 'footer',
'weight' => 100,
));
drupal_add_js($twentytwenty_path . '/js/jquery.twentytwenty.js', array(
'scope' => 'footer',
'weight' => 110,
));
drupal_add_js('jQuery(window).load(function () { jQuery(".twentytwenty-container").twentytwenty({default_offset_pct: ' . $settings['default_offset_pct'] . '}); });', array(
'type' => 'inline',
'scope' => 'footer',
'weight' => 120,
));
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' => 'zurb_twentytwenty',
'#items' => $items,
'#images' => $images,
'#options' => array(
'image_style' => $settings['image_style'],
'default_offset_pct' => $settings['default_offset_pct'],
),
'#entity' => $entity,
);
}
return $element;
}