function template_preprocess_field_slideshow_pager in Field Slideshow 8
Same name and namespace in other branches
- 8.2 field_slideshow.module \template_preprocess_field_slideshow_pager()
- 7.2 field_slideshow.module \template_preprocess_field_slideshow_pager()
- 7 field_slideshow.module \template_preprocess_field_slideshow_pager()
Implements template_preprocess().
File
- ./
field_slideshow.module, line 180 - Preprocess and theme hook functions.
Code
function template_preprocess_field_slideshow_pager(&$variables) {
$items = $variables['items'];
$fc_image_field = $variables['fc_image_field'];
// Add thumbnails pager/carousel if needed
if (isset($variables['pager']) && ($variables['pager'] == 'image' || $variables['pager'] == 'carousel')) {
if ($variables['pager'] == 'carousel') {
$thumbnail_style = $variables['carousel_image_style'];
//$path = libraries_get_path('jquery.jcarousel');
$path = DRUPAL_ROOT . '/libraries/jquery.jcarousel';
if (isset($variables['carousel_skin']) && $variables['carousel_skin']) {
$variables['#attached']['library'][] = 'field_slideshow/field_slideshow.field_slideshow.jquery.carousel.skin.' . $variables['carousel_skin'];
}
}
else {
$thumbnail_style = $variables['pager_image_style'];
}
$thumbnails = array();
foreach ($items as $num => $item) {
$thumbnail = array();
if (!empty($variables['check'])) {
$thumbnail['path'] = $item
->getValue()['fc_thumbnail_path'];
}
else {
$thumbnail['path'] = $item->entity
->getFileUri();
}
$thumbnail['attributes'] = $item->_attributes;
$thumbnail['attributes']['class'] = array(
'field-slideshow-thumbnail',
'field-slideshow-thumbnail-' . (1 + $num),
);
$thumbnail['alt'] = isset($item->alt) ? $item->alt : '';
if (isset($item->width) && isset($item->height)) {
$thumbnail['width'] = $item->width;
$thumbnail['height'] = $item->height;
}
else {
$thumbnail_dims = getimagesize($thumbnail['path']);
$thumbnail['width'] = $thumbnail_dims[0];
$thumbnail['height'] = $thumbnail_dims[1];
}
if (isset($item->title) && strlen($item->title) > 0) {
$thumbnail['title'] = $item->title;
}
// @todo: need to add cache tags in image.
if (!empty($variables['check'])) {
$fc_image_item = $item
->getFieldCollectionItem()
->get($fc_image_field)
->first();
$thumbnail_output = array(
'#theme' => 'image_formatter',
'#item' => $fc_image_item,
'#item_attributes' => $thumbnail['attributes'],
'#url' => "#",
);
}
else {
$thumbnail_output = array(
'#theme' => 'image_formatter',
'#item' => $item,
'#item_attributes' => $thumbnail['attributes'],
'#url' => "#",
);
}
if ($thumbnail_style) {
$thumbnail_output['#image_style'] = $thumbnail_style;
}
$thumbnails[] = $thumbnail_output;
}
$variables['thumbnails'] = array(
'#theme' => 'item_list',
'#items' => $thumbnails,
'#attributes' => array(
'id' => 'field-slideshow-' . $variables['slideshow_id'] . '-pager',
'class' => 'field-slideshow-pager slides-' . count($items),
),
);
}
$variables['items_count'] = count($items);
}