Change record status: 
Project: 
Introduced in branch: 
8.x
Description: 

Site builders are able now to add 'alt' and 'title' attributes to the default image of an image field. The image field formatter will output the 'alt' and 'title' attributes along with 'width' and 'height' that are computed.

Internally the default image is represented now as an associative array instead of a file id reference integer. The default_image field and instance setting is an associative array having the next keys:

  • fid: File ID reference.
  • alt: The 'alt' attribute.
  • title: The 'title' attribute.
  • width: The default image width (computed).
  • height: The default image height (computed).

Drupal 7

function image_field_info() {
  return array(
    'image' => array(
      ...
      'settings' => array(
        ...
        'default_image' => 0,
      ),
      'instance_settings' => array(
        ...
        'default_image' => 0,
      ),
      ...
    ),
  );
}

Drupal 8

/**
 * Plugin implementation of the 'image' field type.
 *
 * @FieldType(
 *   id = "image",
     ...
 *   settings = {
       ...
 *     "default_image" = {
 *       "fid" = NULL,
 *       "alt" = "",
 *       "title" = "",
 *       "width" = NULL,
 *       "height" = NULL
 *     },
       ...
 *   },
 *   instance_settings = {
       ...
 *     "default_image" = {
 *       "fid" = NULL,
 *       "alt" = "",
 *       "title" = "",
 *       "width" = NULL,
 *       "height" = NULL
 *     }
 *   },
     ...
 * )
 */
class ImageItem extends FileItem {
   ...
}
Impacts: 
Site builders, administrators, editors
Module developers
Themers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Not done