function template_preprocess_image_insert_image in Insert 7
Theme the content that will be inserted for Image styles.
File
- includes/
image.inc, line 58 - Insert support for ImageField module.
Code
function template_preprocess_image_insert_image(&$vars) {
// Determine dimensions of the image after the image style transformations.
$image_info = @image_get_info($vars['item']['uri']);
$vars['width'] = isset($image_info['width']) ? $image_info['width'] : NULL;
$vars['height'] = isset($image_info['height']) ? $image_info['height'] : NULL;
image_style_transform_dimensions($vars['style_name'], $vars);
$vars['uri'] = image_style_path($vars['style_name'], $vars['item']['uri']);
$absolute = isset($vars['widget']['settings']['insert_absolute']) ? $vars['widget']['settings']['insert_absolute'] : NULL;
$vars['url'] = insert_create_url($vars['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($vars['style_name'], $vars['item']['uri']),
);
$vars['url'] .= (strpos($vars['url'], '?') !== FALSE ? '&' : '?') . drupal_http_build_query($token_query);
}
$vars['class'] = !empty($vars['widget']['settings']['insert_class']) ? $vars['widget']['settings']['insert_class'] : '';
}