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

Preprocess variables for the colorbox-insert-image.tpl.php file.

@codingStandardsIgnoreStart

Parameters

array $variables: Array with variables values.

File

./colorbox.theme.inc, line 226

Code

function template_preprocess_colorbox_insert_image(&$variables) {
    // @codingStandardsIgnoreEnd
    $item = $variables['item'];
    $variables['file'] = file_load($item['fid']);
    $variables['style_name'] = $item['style_name'];
    $variables['width'] = isset($item['width']) ? $item['width'] : NULL;
    $variables['height'] = isset($item['height']) ? $item['height'] : NULL;
    // Determine dimensions of the image after the image style transformations.
    image_style_transform_dimensions($variables['style_name'], $variables);
    $class = array();
    if (!empty($variables['widget']['settings']['insert_class'])) {
        $class = explode(' ', $variables['widget']['settings']['insert_class']);
    }
    $class[] = 'image-' . $variables['style_name'];
    foreach ($class as $key => $value) {
        $class[$key] = drupal_html_class($value);
    }
    $variables['class'] = implode(' ', $class);
    $variables['uri'] = image_style_path($variables['style_name'], $variables['file']->uri);
    $absolute = isset($variables['widget']['settings']['insert_absolute']) ? $variables['widget']['settings']['insert_absolute'] : NULL;
    $variables['url'] = insert_create_url($variables['uri'], $absolute, variable_get('clean_url'));
    // http://drupal.org/node/1923336
    if (function_exists('image_style_path_token')) {
        $token_query = array(
            IMAGE_DERIVATIVE_TOKEN => image_style_path_token($variables['style_name'], $variables['file']->uri),
        );
        $variables['url'] .= (strpos($variables['url'], '?') !== FALSE ? '&' : '?') . drupal_http_build_query($token_query);
    }
    if ($style_name = variable_get('colorbox_image_style', '')) {
        $variables['path'] = image_style_url($style_name, $variables['file']->uri);
    }
    else {
        $variables['path'] = file_create_url($variables['file']->uri);
    }
    $variables['gallery_id'] = '';
    switch (variable_get('colorbox_insert_gallery', 0)) {
        case 0:
        case 1:
        case 2:
            $variables['gallery_id'] = 'gallery-all';
            break;
        case 3:
            $variables['gallery_id'] = '';
            break;
    }
}