4.6.x theme.inc theme_image($path, $alt = '', $title = '', $attr = '', $getsize = true)
4.7.x theme.inc theme_image($path, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE)
5.x theme.inc theme_image($path, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE)
6.x theme.inc theme_image($path, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE)
7.x theme.inc theme_image($variables)

Return a themed image.


$path: Either the path of the image file (relative to base_path()) or a full URL. If this is a full URL, $getsize must be set to FALSE or nothing will be returned.

$alt: The alternative text for text-based browsers.

$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.

$getsize: If set to TRUE, the image's dimension are fetched and added as width/height attributes. Defaults to TRUE. Must be set to FALSE if $path is a full URL.

Return value

A string containing the image tag.

Related topics

10 theme calls to theme_image()
color_form_alter in modules/color/color.module
Implementation of hook_form_alter().
dblog_overview in modules/dblog/dblog.admin.inc
Menu callback; displays a listing of log messages.
forum-icon.tpl.php in modules/forum/forum-icon.tpl.php
forum-icon.tpl.php Display an appropriate icon for a forum post.
system_themes_form in modules/system/system.admin.inc
Menu callback; displays a listing of all themes.
system_theme_select_form in modules/system/system.module
Returns a fieldset containing the theme select form.

... See full list


includes/theme.inc, line 1286
The theme system, which controls the output of Drupal.


function theme_image($path, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE) {
  if (!$getsize || is_file($path) && (list($width, $height, $type, $image_attributes) = @getimagesize($path))) {
    $attributes = drupal_attributes($attributes);
    $url = url($path) == $path ? $path : base_path() . $path;
    return '<img src="' . check_url($url) . '" alt="' . check_plain($alt) . '" title="' . check_plain($title) . '" ' . (isset($image_attributes) ? $image_attributes : '') . $attributes . ' />';


hadsie’s picture

If you're using theme_image() on a URL instead of a path set $getsize = FALSE or this function won't have a return value.