Same name and namespace in other branches
  1. 7.x-1.x colorbox.theme.inc \theme_colorbox_imagefield() 1 comment

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

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);
}