diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index b65b71e..e815bfa 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -1724,10 +1724,12 @@ function theme_links($variables) {
}
/**
- * Returns HTML for an image.
+ * Prepares variables for image templates.
*
- * @param $variables
- * An associative array containing:
+ * Default template: image.html.twig.
+ *
+ * @param array $variables
+ * Available variables:
* - uri: Either the path of the image file (relative to base_path()) or a
* full URL.
* - width: The width of the image (if known).
@@ -1746,17 +1748,14 @@ function theme_links($variables) {
* popular browsers.
* - attributes: Associative array of attributes to be placed in the img tag.
*/
-function theme_image($variables) {
- $attributes = $variables['attributes'];
- $attributes['src'] = file_create_url($variables['uri']);
+function template_preprocess_image(&$variables) {
+ $variables['attributes']['src'] = file_create_url($variables['uri']);
foreach (array('width', 'height', 'alt', 'title') as $key) {
- if (isset($variables[$key])) {
- $attributes[$key] = $variables[$key];
+ if (!empty($variables[$key])) {
+ $variables['attributes'][$key] = $variables[$key];
}
}
-
- return '';
}
/**
@@ -3032,6 +3031,7 @@ function drupal_common_theme() {
// The title attribute is optional in all cases, so it is omitted by
// default.
'variables' => array('uri' => NULL, 'width' => NULL, 'height' => NULL, 'alt' => '', 'title' => NULL, 'attributes' => array()),
+ 'template' => 'image',
),
'breadcrumb' => array(
'variables' => array('breadcrumb' => NULL),
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageThemeFunctionTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageThemeFunctionTest.php
index 1f00c21..3958345 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageThemeFunctionTest.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageThemeFunctionTest.php
@@ -63,9 +63,10 @@ function testImageFormatterTheme() {
// 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);
- $expected_result = '';
- $this->assertEqual($expected_result, $rendered_element, 'theme_image_formatter() correctly renders without title, alt, or path options.');
+ $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.
$fragment = $this->randomName();
@@ -74,9 +75,10 @@ function testImageFormatterTheme() {
'external' => TRUE,
'fragment' => $fragment,
);
- $rendered_element = render($element);
- $expected_result = '';
- $this->assertEqual($expected_result, $rendered_element, 'theme_image_formatter() correctly renders a link fragment.');
+
+ $this->drupalSetContent(render($element));
+ $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.');
}
/**
@@ -99,9 +101,9 @@ function testImageStyleTheme() {
'#style_name' => 'image_test',
'#uri' => $original_uri,
);
- $rendered_element = render($element);
- $expected_result = '';
- $this->assertEqual($expected_result, $rendered_element, 'theme_image_style() renders an image correctly.');
+ $this->drupalSetContent(render($element));
+ $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;
diff --git a/core/modules/system/templates/image.html.twig b/core/modules/system/templates/image.html.twig
new file mode 100644
index 0000000..8572410
--- /dev/null
+++ b/core/modules/system/templates/image.html.twig
@@ -0,0 +1,14 @@
+{#
+/**
+ * @file
+ * Default theme implementation of an image.
+ *
+ * Available variables:
+ * - attributes: HTML attributes for the img tag.
+ *
+ * @see template_preprocess_image()
+ *
+ * @ingroup themeable
+ */
+#}
+{# This comment removes newline character. #}
diff --git a/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php b/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php
index fcae023..8c24b08 100644
--- a/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php
+++ b/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php
@@ -88,8 +88,9 @@ public function testTourFunctionality() {
));
$this->assertNotEqual(count($elements), 1, 'Did not find Italian variant of tip 1.');
- // Ensure that plugin's work.
- $this->assertRaw('img src="http://local/image.png"', 'Image plugin tip found.');
+ // Ensure that plugins work.
+ $elements = $this->xpath('//img[@src="http://local/image.png"]');
+ $this->assertEqual(count($elements), 1, 'Image plugin tip found.');
// Navigate to tour-test-2/subpath and verify the tour_test_2 tip is found.
$this->drupalGet('tour-test-2/subpath');