Hello,
I use image_caption module and it needs width attribute.
Please add these lines into template_preprocess_colorbox_insert_image()

$image_style_path = image_style_path($vars['item']['style_name'], $file->uri);
$image_info = image_get_info($image_style_path);
$variables['width'] = isset($image_info['width']) ? $image_info['width'] : '';
$variables['height'] = isset($image_info['height']) ? $image_info['height'] : '';

and update colorbox-insert-image.tpl.php

Thanks

Comments

joglin’s picture

Ooops! We must first create derivative.

  $image_style_path = image_style_path($variables['item']['style_name'], $file->uri);
  if (!$style_path_exists = file_exists($image_style_path)) {
     if ($image_style = image_style_load($variables['item']['style_name'])) {
      $style_path_exists = image_style_create_derivative($image_style, $file->uri, $image_style_path);
     }
  }
  $image_info = FALSE;
  if ($style_path_exists) {
    $image_info = image_get_info($image_style_path);
  }
  $variables['width'] = isset($image_info['width']) ? $image_info['width'] : '';
  $variables['height'] = isset($image_info['height']) ? $image_info['height'] : ''; 
frjo’s picture

Status: Active » Needs work

Get it added to the insert module first then I will add it to Colorbox.

joglin’s picture

I read this discussion: Calculate width and height attributes when inserting ImageCache images and I realized that this feature is more complicated than I thought. Only a very specific filter solves complexity of this issue and Image Resize Filter is good for me, actually.

Thanks.

frjo’s picture

Status: Needs work » Closed (won't fix)