You are here

function image_field_caption_theme_image in Image Field Caption 7

After hook_theme_registry_alter makes its alterations, this function provides the routing to properly theme the image and the caption.

1 string reference to 'image_field_caption_theme_image'
image_field_caption_theme_registry_alter in ./image_field_caption.module
Implements hook_theme_registry_alter().

File

./image_field_caption.module, line 288
Provides a caption textarea for image fields.

Code

function image_field_caption_theme_image($variables) {

  // Depending on the image theme type, call the appropriate image theme
  // function, then pull out any caption.
  $image = '';
  $caption = '';
  switch ($variables['image_field_caption_type']) {
    case 'image_formatter':
      $image = theme_image_formatter($variables);
      if (isset($variables['item']['caption'])) {
        $caption = $variables['item']['caption'];
      }
      break;
    case 'image_style':
      $image = theme_image_style($variables);
      if (isset($variables['caption'])) {
        $caption = $variables['caption'];
      }
      break;
  }

  // Now that Drupal has rendered the image, if there was a caption let's
  // render the image and the caption, otherwise just return the already
  // rendered image.
  if ($caption != '') {
    return theme('image_field_caption', array(
      'image' => $image,
      'caption' => filter_xss($caption, explode(',', image_field_captions_allowed_tags())),
    ));
  }
  else {
    return $image;
  }
}