You are here

function theme_colorbox_imagefield in Colorbox 7.2

Same name and namespace in other branches
  1. 6 colorbox.theme.inc \theme_colorbox_imagefield()
  2. 7 colorbox.theme.inc \theme_colorbox_imagefield()

Returns HTML for an image using a specific Colorbox image style.

@codingStandardsIgnoreStart

Parameters

array $variables: An associative array containing:

  • image: image item as array.
  • path: The path of the image that should be displayed in the Colorbox.
  • title: The title text that will be used as a caption in the Colorbox.
  • gid: Gallery id for Colorbox image grouping.

Return value

string An HTML string containing a link to the given path.

1 theme call to theme_colorbox_imagefield()
theme_colorbox_image_formatter in ./colorbox.theme.inc
Returns HTML for an Colorbox image field formatter.

File

./colorbox.theme.inc, line 189
Colorbox theme functions.

Code

function theme_colorbox_imagefield($variables) {

  // @codingStandardsIgnoreEnd
  $class = array(
    'colorbox',
  );
  if ($variables['image']['style_name'] == 'hide') {
    $image = '';
    $class[] = 'js-hide';
  }
  elseif (!empty($variables['image']['style_name'])) {
    $image = theme('image_style', $variables['image']);
  }
  else {
    $image = theme('image', $variables['image']);
  }
  $options = drupal_parse_url($variables['path']);
  $options += array(
    'html' => TRUE,
    'attributes' => array(
      'title' => $variables['title'],
      'class' => $class,
      'data-colorbox-gallery' => $variables['gid'],
      'data-cbox-img-attrs' => '{"title": "' . $variables['image']['title'] . '", "alt": "' . $variables['image']['alt'] . '"}',
    ),
  );
  return l($image, $options['path'], $options);
}