Experimental project

This is a sandbox project, which contains experimental code for developer use only.

Imagefield attributes works in a similar way that ImageField extended worked in Drupal 6 by allowing site administrators to add custom attributes to image instances and then allowing content administrators to fill in those attributes.

Why Imagefield attributes?

Imagefield attributes is a more lightweight and targeted solution then file entities or field collections. The module will work on existing sites and is completely non destructive meaning none of your imagefields will be broken or have to be reconfigured (repurposing a site to use field collections or file entities can be time consuming and risky on existing builds).


The module works makes use of Drupal caching and static caching mechanisms to deliver the best possible performance. On sites with thousands of images with multiple attribute values you may begin to hit performance issues however null value attributes are not stored in the database so only images with attributes are recorded.

How to use

  1. Enable the module.
  2. Edit the image field you'd like to add attributes to. (For example, if the field you'd like to edit is within a node, go to content types; manage fields; and click the edit link next to the field.
  3. Under 'Image attributes' click 'add'
  4. Give your attribute an administrative title, an attribute name (eg longdesc or data-href) and a default value.
  5. Edit the content which contains the imagefield and change the attributes.


As discussed before http://drupal.org/project/file_entity and http://drupal.org/project/field_collection offer fully featured alternatives however they're configuration heavy and may involve modifying fields you've already configured and built.

Use cases

  • Some JavaScript libraries use attributes to provide extended functionality for example Galleria uses the 'data-link' attribute to allow slideshow images to be linkable.
  • Additional ARIA tags can be used to increase the accessibility of images. For more information visit http://www.w3.org/TR/wai-aria/roles#img.

Project Information