Commit 5f98fb81 authored by Dries's avatar Dries

- Patch #555830 by sun, effulgentsia, mgifford, TheRec, aspilicious: clean up...

- Patch #555830 by sun, effulgentsia, mgifford, TheRec, aspilicious: clean up theme_image() to use drupal_attributes() for all attributes and revisit defaults for 'alt' and 'title'.
parent 7d83f7c8
......@@ -5390,7 +5390,7 @@ function drupal_common_theme() {
'variables' => array('links' => NULL, 'attributes' => array('class' => array('links')), 'heading' => array()),
),
'image' => array(
'variables' => array('path' => NULL, 'alt' => '', 'title' => '', 'attributes' => array(), 'getsize' => TRUE),
'variables' => array('path' => NULL, 'alt' => '', 'title' => NULL, 'attributes' => array(), 'getsize' => TRUE),
),
'breadcrumb' => array(
'variables' => array('breadcrumb' => NULL),
......
......@@ -1484,10 +1484,27 @@ function theme_image($variables) {
$attributes = $variables['attributes'];
$getsize = $variables['getsize'];
if (!$getsize || (is_file($path) && (list($width, $height, $type, $image_attributes) = @getimagesize($path)))) {
$attributes = drupal_attributes($attributes);
$url = file_create_url($path);
return '<img src="' . check_url($url) . '" alt="' . check_plain($alt) . '" title="' . check_plain($title) . '" ' . (isset($image_attributes) ? $image_attributes : '') . $attributes . ' />';
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;
}
return '<img' . drupal_attributes($attributes) . ' />';
}
}
......
......@@ -511,8 +511,11 @@ function theme_image_formatter($variables) {
$image = array(
'path' => $item['uri'],
'alt' => $item['alt'],
'title' => $item['title'],
);
// Do not output an empty 'title' attribute.
if (drupal_strlen($item['title']) > 0) {
$image['title'] = $item['title'];
}
if ($variables['image_style']) {
$image['style_name'] = $variables['image_style'];
......
......@@ -178,7 +178,7 @@ function image_theme() {
'style_name' => NULL,
'path' => NULL,
'alt' => '',
'title' => '',
'title' => NULL,
'attributes' => array(),
'getsize' => TRUE,
),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment