rodericksandoval
7/10/2014 - 11:33 PM

flexslider colorbox enabled images

flexslider colorbox enabled images

/**
 * Overriding flexslider_list theme implementation to output colorbox enabled images
 * https://www.drupal.org/node/1553648
 */
function raiz_flexslider_list(&$vars) {
  // Reference configuration variables
  $optionset = &$vars['settings']['optionset'];
  $items = &$vars['items'];
  $attributes = &$vars['settings']['attributes'];
  $type = &$vars['settings']['type'];
  $output = '';
  $group = $optionset->title;
  // Build the list
  if (!empty($items)) {
    $output .= "<$type" . drupal_attributes($attributes) . '>';
    foreach ($items as $i => $item) {
      $caption = '';
      if (!empty($item['caption'])) {
        $caption = $item['caption'];
      }
      // Build path to colorbox image style. Replace 'colorbox' with your image style name.
      $colorbox_path = image_style_url('colorbox', $item['item']['uri']);
      $image_options = array(
        'style_name' => $optionset->imagestyle_normal,
        'path'       => $item['item']['uri'],
        'height'     => $item['item']['height'],
        'width'      => $item['item']['width'],
        'alt'        => $item['item']['alt'],
        'title'      => $item['item']['title'],
      );
      $item['slide'] = theme('colorbox_imagefield', array('image' => $image_options, 'path' => $colorbox_path, 'title' => $caption, 'gid' => array('rel' => $group)));
      $output .= theme('flexslider_list_item', array(
        'item' => $item['slide'],
        'settings' => array(
          'optionset' => $optionset,
        ),
        'caption' => $caption,
      ));
    }
    $output .= "</$type>";
  }
  return $output;
}