function theme_lazy_image_formatter in Lazy-load 7
Returns HTML for an image field formatter.
Parameters
$variables: An associative array containing:
- item: Associative array of image data, which may include "uri", "alt", "width", "height", "title" and "attributes".
- image_style: An optional image style.
- path: An array containing the link 'path' and link 'options'.
1 theme call to theme_lazy_image_formatter()
- lazy_field_formatter_view in ./
lazy.module - Implements hook_field_formatter_view().
File
- ./
lazy.module, line 549 - Module file for Lazy-load.
Code
function theme_lazy_image_formatter($variables) {
$item = $variables['item'];
$image = array(
'path' => $item['uri'],
);
if (array_key_exists('alt', $item)) {
$image['alt'] = $item['alt'];
}
if (isset($item['attributes'])) {
$image['attributes'] = $item['attributes'];
}
if (isset($item['width'], $item['height'])) {
$image['width'] = $item['width'];
$image['height'] = $item['height'];
}
// Do not output an empty 'title' attribute.
if (isset($item['title']) && drupal_strlen($item['title']) > 0) {
$image['title'] = $item['title'];
}
if ($variables['image_style']) {
$image['style_name'] = $variables['image_style'];
}
$output = theme('lazy_image', $image);
// 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;
}