summaryrefslogtreecommitdiff
path: root/modules/image
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2012-02-28 23:10:07 -0800
committerwebchick <webchick@24967.no-reply.drupal.org>2012-02-28 23:10:07 -0800
commit312769b7d74c868beaa27309cd120e596b61e8a4 (patch)
tree406d3e58993766b252b7365389aff15f1e65c770 /modules/image
parente7d02a1ba04b31a344226856c2fb068d3f9acd75 (diff)
downloadbrdo-312769b7d74c868beaa27309cd120e596b61e8a4.tar.gz
brdo-312769b7d74c868beaa27309cd120e596b61e8a4.tar.bz2
Issue #1329586 by Rob Loach, tim.plunkett, jthorson: Theme_image_formatter() should pass along attributes.
Diffstat (limited to 'modules/image')
-rw-r--r--modules/image/image.field.inc7
-rw-r--r--modules/image/image.test17
2 files changed, 23 insertions, 1 deletions
diff --git a/modules/image/image.field.inc b/modules/image/image.field.inc
index 3692ee2e8..e56e0cf49 100644
--- a/modules/image/image.field.inc
+++ b/modules/image/image.field.inc
@@ -568,7 +568,8 @@ function image_field_formatter_view($entity_type, $entity, $field, $instance, $l
*
* @param $variables
* An associative array containing:
- * - item: An array of image data.
+ * - 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'.
*
@@ -581,6 +582,10 @@ function theme_image_formatter($variables) {
'alt' => $item['alt'],
);
+ if (isset($item['attributes'])) {
+ $image['attributes'] = $item['attributes'];
+ }
+
if (isset($item['width']) && isset($item['height'])) {
$image['width'] = $item['width'];
$image['height'] = $item['height'];
diff --git a/modules/image/image.test b/modules/image/image.test
index 3b7f3e7d7..8ec77587b 100644
--- a/modules/image/image.test
+++ b/modules/image/image.test
@@ -808,6 +808,23 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase {
}
/**
+ * Test passing attributes into the image field formatters.
+ */
+ function testImageFieldFormatterAttributes() {
+ $image = theme('image_formatter', array(
+ 'item' => array(
+ 'uri' => 'http://example.com/example.png',
+ 'attributes' => array(
+ 'data-image-field-formatter' => 'testFound',
+ ),
+ 'alt' => t('Image field formatter attribute test.'),
+ 'title' => t('Image field formatter'),
+ ),
+ ));
+ $this->assertTrue(stripos($image, 'testFound') > 0, t('Image field formatters can have attributes.'));
+ }
+
+ /**
* Test use of a default image with an image field.
*/
function testImageFieldDefaultImage() {