You are here

function theme_bxslider_colorbox in BxSlider 7

Theme function for integration Colorbox.

1 theme call to theme_bxslider_colorbox()
bxslider_field_formatter_view in ./bxslider.module
Implements hook_field_formatter_view().

File

./bxslider.module, line 1301
Fields integration with BxSlider.

Code

function theme_bxslider_colorbox(&$vars) {
  $slide = $vars['slide_item']['slide'];
  if ($vars['settings']['colorbox']['enable']) {
    if (!empty($vars['settings']['colorbox']['image_style'])) {
      $style = image_style_load($vars['settings']['colorbox']['image_style']);
      $colorbox_style_path = image_style_path($vars['settings']['colorbox']['image_style'], $vars['slide_item']['item']['uri']);
      image_style_create_derivative($style, $vars['slide_item']['item']['uri'], $colorbox_style_path);
      $thumbnail_parameters = image_get_info($colorbox_style_path);
      $width = $thumbnail_parameters['width'];
      $height = $thumbnail_parameters['height'];
    }
    else {

      // Original image.
      $colorbox_style_path = file_create_url($vars['slide_item']['item']['uri']);
      $width = $vars['slide_item']['item']['width'];
      $height = $vars['slide_item']['item']['height'];
    }
    $attributes = array(
      'class' => 'colorbox-load',
      // Used for combination of elements together for a gallery.
      'rel' => 'bx-' . $vars['slide_item']['item']['rel'],
    );
    $options = array(
      'width' => $width,
      'height' => $height,
    );
    if (isset($vars['settings']['colorbox']['slideshow']) && $vars['settings']['colorbox']['slideshow']) {
      $options["slideshow"] = "true";
      $options["slideshowAuto"] = $vars['settings']['colorbox']['slideshow'] == 'automatic' ? 'true' : 'false';
      $options["slideshowSpeed"] = $vars['settings']['colorbox']['slideshow_speed'];
      $options["transition"] = $vars['settings']['colorbox']['transition'];
      $options["speed"] = $vars['settings']['colorbox']['transition_speed'];
    }
    $slide = l($slide, file_create_url($colorbox_style_path), array(
      'attributes' => $attributes,
      'html' => TRUE,
      'query' => $options,
    ));
  }
  return $slide;
}