I would like to add a couple of lines of code to the theme_image_formatter function found in image.field.inc which would allow attributes set on render arrays to be passed onto the theme image functions: -

  // Do not output an empty 'title' attribute.
  if (drupal_strlen($item['title']) > 0) {
    $image['title'] = $item['title'];
  }

+ // Pass on any attributes
+   if(isset($item['attributes'])) {
+   	$image['attributes'] = $item['attributes'];
+   }

  if ($variables['image_style']) {
    $image['style_name'] = $variables['image_style'];

Sorry for not adding a patch - it isn't easy for me to do here :-(

Comments

esbite’s picture

Status: Active » Closed (duplicate)

Just found this has already been committed to core. Happy day!

http://drupal.org/node/1329586