function flexslider_picture_field_formatter_view in Picture 7
Same name and namespace in other branches
- 7.2 flexslider_picture/flexslider_picture.module \flexslider_picture_field_formatter_view()
Implements hook_field_formatter_view().
Prepares a renderable array of images and adds the neccessary JS and CSS
File
- flexslider_picture/
flexslider_picture.module, line 64 - Picture formatter with flexslider support.
Code
function flexslider_picture_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = flexslider_fields_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display);
$optionsets = array();
foreach (element_children($element) as $child) {
if (!isset($optionsets[$element[$child]['#settings']['optionset']])) {
$optionsets[$element[$child]['#settings']['optionset']] = flexslider_optionset_load($element[$child]['#settings']['optionset']);
}
$optionset = $optionsets[$element[$child]['#settings']['optionset']];
if ($optionset && isset($optionset->imagestyle_type) && !empty($optionset->imagestyle_type) && $optionset->imagestyle_type == 'picture_mapping') {
$element[$child]['#attached'] = array(
'library' => array(
array(
'picture',
'matchmedia',
),
array(
'picture',
'picturefill',
),
array(
'picture',
'picture.ajax',
),
),
);
}
}
return $element;
}