1 theme.inc theme_image($variables)

Returns HTML for an image.

Either a "uri" or "path" should be provided to the image. URIs should be used for files that are stored in the public or private file directories. Paths should be used for images relative to the Backdrop installation.

@since 1.8.0 Added support for $variables['path']. All variables are now populated into $variables['attributes'] in template_preprocess_image().


$variables: An associative array containing:

  • uri: A file URI, prefixed with a file scheme such as public://
  • path: A file path relative to the root of the Backdrop installation.
  • width: The width of the image (if known).
  • height: The height of the image (if known).
  • alt: The alternative text for text-based browsers. HTML 4 and XHTML 1.0 always require an alt attribute. The HTML 5 draft allows the alt attribute to be omitted in some cases. Therefore, this variable defaults to an empty string, but can be set to NULL for the attribute to be omitted. Usually, neither omission nor an empty string satisfies accessibility requirements, so it is strongly encouraged for code calling theme('image') to pass a meaningful value for this variable.

  • title: The title text is displayed when the image is hovered in some popular browsers.
  • attributes: Associative array of attributes to be placed in the img tag. All attributes should be populated with the correct values that match the other input variables.

Related topics


core/includes/theme.inc, line 2037
The theme system, which controls the output of Backdrop.


function theme_image($variables) {
  return '<img' . backdrop_attributes($variables['attributes']) . ' />';