1 image.theme.inc theme_image_formatter($variables)

Returns HTML for an image field formatter.


$variables: An associative array containing:

  • item: An array of image data.
  • image_style: An optional image style.
  • path: An optional array containing the link 'path' and link 'options'.

Related topics


core/modules/image/image.theme.inc, line 381
Theme functions for the Image module.


function theme_image_formatter($variables) {
  $item = $variables['item'];

  // Do not output an empty 'title' attribute.
  if (isset($item['title']) && backdrop_strlen($item['title']) == 0) {

  if ($variables['image_style']) {
    $item['style_name'] = $variables['image_style'];
    $output = theme('image_style', $item);
  else {
    $output = theme('image', $item);

  // The link path and link options are both optional, but for the options to be
  // processed, the link path must at least be an empty string.
  if (isset($variables['path']['path'])) {
    $path = $variables['path']['path'];
    $options = isset($variables['path']['options']) ? $variables['path']['options'] : array();
    // When displaying an image inside a link, the html option must be TRUE.
    $options['html'] = TRUE;
    $output = l($output, $path, $options);

  return $output;