function theme_picture_formatter

Returns HTML for a picture field formatter.

Parameters

array $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'.
  • breakpoints: An array containing breakpoints.

Related topics

1 theme call to theme_picture_formatter()
PictureFormatter::viewElements in drupal/core/modules/picture/lib/Drupal/picture/Plugin/field/formatter/PictureFormatter.php
Builds a renderable array for a field value.

File

drupal/core/modules/picture/picture.module, line 185
Picture display formatter for image fields.

Code

function theme_picture_formatter($variables) {
  if (!isset($variables['breakpoints']) || empty($variables['breakpoints'])) {
    return theme('image_formatter', $variables);
  }
  $item = $variables['item'];

  // Do not output an empty 'title' attribute.
  if (isset($item['title']) && drupal_strlen($item['title']) == 0) {
    unset($item['title']);
  }
  $item['style_name'] = $variables['image_style'];
  $item['breakpoints'] = $variables['breakpoints'];
  if (!isset($item['path']) && isset($variables['uri'])) {
    $item['path'] = $variables['uri'];
  }
  $output = theme('picture', $item);
  if (isset($variables['path']['path'])) {
    $path = $variables['path']['path'];
    $options = isset($variables['path']['options']) ? $variables['path']['options'] : array();
    $options['html'] = TRUE;
    $output = l($output, $path, $options);
  }
  return $output;
}