diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 162a833..8a9bf9f 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -1768,7 +1768,7 @@ function template_preprocess_image(&$variables) {
$variables['attributes']['src'] = file_create_url($variables['uri']);
foreach (array('width', 'height', 'alt', 'title') as $key) {
- if (!empty($variables[$key])) {
+ if (isset($variables[$key])) {
$variables['attributes'][$key] = $variables[$key];
}
}
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageThemeFunctionTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageThemeFunctionTest.php
index 9339685..6185f15 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageThemeFunctionTest.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageThemeFunctionTest.php
@@ -56,17 +56,15 @@ function testImageFormatterTheme() {
'path' => $path,
),
);
- $rendered_element = render($element);
- $expected_result = '
-';
- $this->assertEqual($expected_result, $rendered_element, 'theme_image_formatter() correctly renders with a NULL value for the alt option.');
+ $this->drupalSetContent(render($element));
+ $elements = $this->xpath('//a[@href=:path]/img[@class="image-style-test" and @src=:url]', array(':path' => base_path() . $path, ':url' => $url));
+ $this->assertEqual(count($elements), 1, 'theme_image_formatter() correctly renders with a NULL value for the alt option.');
// Test using theme_image_formatter() without an image title, alt text, or
// link options.
unset($element['#item']['alt']);
$this->drupalSetContent(render($element));
- $rendered_element = render($element);
- $elements = $this->xpath('//a[@href=:path]/img[@class="image-style-test" and @src=:url]', array(':path' => base_path() . $path, ':url' => $url));
+ $elements = $this->xpath('//a[@href=:path]/img[@class="image-style-test" and @src=:url and @alt=""]', array(':path' => base_path() . $path, ':url' => $url));
$this->assertEqual(count($elements), 1, 'theme_image_formatter() correctly renders without title, alt, or path options.');
// Link the image to a fragment on the page, and not a full URL.
@@ -78,7 +76,7 @@ function testImageFormatterTheme() {
);
$this->drupalSetContent(render($element));
- $elements = $this->xpath('//a[@href=:fragment]/img[@class="image-style-test" and @src=:url]', array(':fragment' => '#' . $fragment, ':url' => $url));
+ $elements = $this->xpath('//a[@href=:fragment]/img[@class="image-style-test" and @src=:url and @alt=""]', array(':fragment' => '#' . $fragment, ':url' => $url));
$this->assertEqual(count($elements), 1, 'theme_image_formatter() correctly renders a link fragment.');
}
@@ -103,15 +101,14 @@ function testImageStyleTheme() {
'#uri' => $original_uri,
);
$this->drupalSetContent(render($element));
- $elements = $this->xpath('//img[@class="image-style-image-test" and @src=:url]', array(':url' => $url));
+ $elements = $this->xpath('//img[@class="image-style-image-test" and @src=:url and @alt=""]', array(':url' => $url));
$this->assertEqual(count($elements), 1, 'theme_image_style() renders an image correctly.');
// Test using theme_image_style() with a NULL value for the alt option.
$element['#alt'] = NULL;
- $rendered_element = render($element);
- $expected_result = '
-';
- $this->assertEqual($expected_result, $rendered_element, 'theme_image_style() renders an image correctly with a NULL value for the alt option.');
+ $this->drupalSetContent(render($element));
+ $elements = $this->xpath('//img[@class="image-style-image-test" and @src=:url]', array(':url' => $url));
+ $this->assertEqual(count($elements), 1, 'theme_image_style() renders an image correctly with a NULL value for the alt option.');
}
}