I have an image field with multiupload (remote source URL) where I also fill out the title text field of each image inserted. However when I try to define the Colorbox caption via tokens in Manage Display, the token for [node:field_image:title] won't work. What I want to get displayed in the caption field is: "[node:title] [node:field_image:title]". After hours of trying I got the code below working for me. What the code does is grabbing any image with image style 140x100_crop and rewrites it but I can't figure out how/where to insert the node title into the image attributes.

function sutok_image(&$variables) {
  $node = menu_get_object();
   $title = $node->title;
   $attributes = $variables['attributes'];
   $attributes['src'] = file_create_url($variables['path']);
   $apply_theming = false;
   $apply_theming_to_variables = array(
      'style_name' => array(
   foreach($apply_theming_to_variables as $var => $val) {
      if(isset($variables[$var]) AND in_array($variables[$var], $val)) {
         $apply_theming = true;
   if(!$apply_theming) { // Return default theming
      return '<img' . drupal_attributes($attributes) . ' />';
   foreach (array('width', 'height', 'alt', 'title') as $key) {
      if(isset($variables[$key])) {
         $attributes[$key] = $variables[$key];
   // Return custom theming
   return '<div style=width:100px;float:left;padding-right:10px;padding-bottom:10px><table><tr><td><img' . drupal_attributes($attributes) . ' /></td></tr><tr><td><center>' . (isset($variables['alt']) ? $variables['alt'] : '') . " " . (isset($variables['title']) ? $variables['title'] : '') . '</center></td></tr></table></div>';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.