diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/common.inc | 2 | ||||
-rw-r--r-- | includes/theme.inc | 35 |
2 files changed, 10 insertions, 27 deletions
diff --git a/includes/common.inc b/includes/common.inc index 6c679857b..e74d1c0a7 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -5842,7 +5842,7 @@ function drupal_common_theme() { // - http://dev.w3.org/html5/spec/Overview.html#alt // The title attribute is optional in all cases, so it is omitted by // default. - 'variables' => array('path' => NULL, 'alt' => '', 'title' => NULL, 'attributes' => array(), 'getsize' => TRUE), + 'variables' => array('path' => NULL, 'width' => NULL, 'height' => NULL, 'alt' => '', 'title' => NULL, 'attributes' => array()), ), 'breadcrumb' => array( 'variables' => array('breadcrumb' => NULL), diff --git a/includes/theme.inc b/includes/theme.inc index 87c8dba50..832f8719d 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -1479,6 +1479,8 @@ function theme_links($variables) { * An associative array containing: * - path: Either the path of the image file (relative to base_path()) or a * full URL. + * - 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 @@ -1492,38 +1494,19 @@ function theme_links($variables) { * - 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. */ function theme_image($variables) { - $path = $variables['path']; - $alt = $variables['alt']; - $title = $variables['title']; $attributes = $variables['attributes']; - $getsize = $variables['getsize']; + $attributes['src'] = file_create_url($variables['path']); - if (!$getsize || (is_file($path) && (list($width, $height) = @getimagesize($path)))) { - // The src attribute can be omitted, by passing NULL for $path and FALSE for - // $getsize. - if (isset($path)) { - $attributes['src'] = file_create_url($path); - } - // The alt attribute defaults to an empty string. By passing NULL as value, - // it can be omitted. - if (isset($alt)) { - $attributes['alt'] = $alt; - } - if (isset($title)) { - $attributes['title'] = $title; - } - if (!isset($attributes['width']) && !empty($width)) { - $attributes['width'] = $width; - } - if (!isset($attributes['height']) && !empty($height)) { - $attributes['height'] = $height; + foreach (array('width', 'height', 'alt', 'title') as $key) { + + if (isset($variables[$key])) { + $attributes[$key] = $variables[$key]; } - return '<img' . drupal_attributes($attributes) . ' />'; } + + return '<img' . drupal_attributes($attributes) . ' />'; } /** |