diff --git a/core/modules/image/image.module b/core/modules/image/image.module
index ccdc879743b500f270520c96156a792b3d8c0d1d..775de2d986d89e2460f40dec7774552efd036e50 100644
--- a/core/modules/image/image.module
+++ b/core/modules/image/image.module
@@ -1205,6 +1205,9 @@ function theme_image_style($variables) {
$variables['width'] = $dimensions['width'];
$variables['height'] = $dimensions['height'];
+ // Add in the image style name as an HTML class.
+ $variables['attributes']['class'][] = 'image-style-' . drupal_html_class($variables['style_name']);
+
// Determine the URL for the styled image.
$variables['uri'] = image_style_url($variables['style_name'], $variables['uri']);
return theme('image', $variables);
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageDimensionsTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageDimensionsTest.php
index d2554cf68bd7d528d8f6ec6ad95b5c7e30ab26ef..76110cf06b59d7307dfb196d475773a7a0b00df8 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageDimensionsTest.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageDimensionsTest.php
@@ -69,7 +69,7 @@ function testImageDimensions() {
image_effect_save('test', $effect);
$img_tag = theme_image_style($variables);
- $this->assertEqual($img_tag, '');
+ $this->assertEqual($img_tag, '');
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
$this->drupalGet($url);
$this->assertResponse(200, t('Image was generated at the URL.'));
@@ -90,7 +90,7 @@ function testImageDimensions() {
image_effect_save('test', $effect);
$img_tag = theme_image_style($variables);
- $this->assertEqual($img_tag, '');
+ $this->assertEqual($img_tag, '');
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
$this->drupalGet($url);
$this->assertResponse(200, t('Image was generated at the URL.'));
@@ -112,7 +112,7 @@ function testImageDimensions() {
image_effect_save('test', $effect);
$img_tag = theme_image_style($variables);
- $this->assertEqual($img_tag, '');
+ $this->assertEqual($img_tag, '');
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
$this->drupalGet($url);
$this->assertResponse(200, t('Image was generated at the URL.'));
@@ -134,7 +134,7 @@ function testImageDimensions() {
image_effect_save('test', $effect);
$img_tag = theme_image_style($variables);
- $this->assertEqual($img_tag, '');
+ $this->assertEqual($img_tag, '');
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
$this->drupalGet($url);
$this->assertResponse(200, t('Image was generated at the URL.'));
@@ -152,7 +152,7 @@ function testImageDimensions() {
image_effect_save('test', $effect);
$img_tag = theme_image_style($variables);
- $this->assertEqual($img_tag, '');
+ $this->assertEqual($img_tag, '');
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
$this->drupalGet($url);
$this->assertResponse(200, t('Image was generated at the URL.'));
@@ -173,7 +173,7 @@ function testImageDimensions() {
image_effect_save('test', $effect);
$img_tag = theme_image_style($variables);
- $this->assertEqual($img_tag, '');
+ $this->assertEqual($img_tag, '');
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
$this->drupalGet($url);
$this->assertResponse(200, t('Image was generated at the URL.'));
@@ -193,7 +193,7 @@ function testImageDimensions() {
image_effect_save('test', $effect);
$img_tag = theme_image_style($variables);
- $this->assertEqual($img_tag, '');
+ $this->assertEqual($img_tag, '');
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
$this->drupalGet($url);
$this->assertResponse(200, t('Image was generated at the URL.'));
@@ -214,7 +214,7 @@ function testImageDimensions() {
$effect = image_effect_save('test', $effect);
$img_tag = theme_image_style($variables);
- $this->assertEqual($img_tag, '');
+ $this->assertEqual($img_tag, '');
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
$this->drupalGet($url);
$this->assertResponse(200, t('Image was generated at the URL.'));
@@ -232,6 +232,6 @@ function testImageDimensions() {
image_effect_save('test', $effect);
$img_tag = theme_image_style($variables);
- $this->assertEqual($img_tag, '');
+ $this->assertEqual($img_tag, '');
}
}
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php
index 601c3c24a32faf671d3937dd2a5b69ee98d72b87..9e00434611959336000967e3ee246895e53e173d 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php
@@ -104,10 +104,11 @@ function _testImageFieldFormatters($scheme) {
// Ensure the derivative image is generated so we do not have to deal with
// image style callback paths.
$this->drupalGet(image_style_url('thumbnail', $image_uri));
- $image_info['uri'] = image_style_path('thumbnail', $image_uri);
+ $image_info['uri'] = $image_uri;
$image_info['width'] = 100;
$image_info['height'] = 50;
- $default_output = theme('image', $image_info);
+ $image_info['style_name'] = 'thumbnail';
+ $default_output = theme('image_style', $image_info);
$this->drupalGet('node/' . $nid);
$this->assertRaw($default_output, t('Image style thumbnail formatter displaying correctly on full node view.'));
@@ -158,11 +159,12 @@ function testImageFieldSettings() {
// style.
$node = node_load($nid, TRUE);
$image_info = array(
- 'uri' => image_style_url('medium', file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri),
+ 'uri' => file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri,
'width' => 220,
'height' => 110,
+ 'style_name' => 'medium',
);
- $default_output = theme('image', $image_info);
+ $default_output = theme('image_style', $image_info);
$this->assertRaw($default_output, t("Preview image is displayed using 'medium' style."));
// Add alt/title fields to the image and verify that they are displayed.
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageThemeFunctionTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageThemeFunctionTest.php
index 0e026f2e4cd2ff41e98c53de615fa8d77c984ce4..45de98e295f0da0fc1cc78fc19a16bcfcf9b4542 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageThemeFunctionTest.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageThemeFunctionTest.php
@@ -56,7 +56,7 @@ function testImageFormatterTheme() {
),
);
$rendered_element = render($element);
- $expected_result = '';
+ $expected_result = '';
$this->assertEqual($expected_result, $rendered_element, '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.
@@ -67,7 +67,7 @@ function testImageFormatterTheme() {
'fragment' => $fragment,
);
$rendered_element = render($element);
- $expected_result = '';
+ $expected_result = '';
$this->assertEqual($expected_result, $rendered_element, 'theme_image_formatter() correctly renders a link fragment.');
}
@@ -81,17 +81,17 @@ function testImageStyleTheme() {
$original_uri = file_unmanaged_copy($file->uri, 'public://', FILE_EXISTS_RENAME);
// Create a style.
- image_style_save(array('name' => 'test'));
- $url = image_style_url('test', $original_uri);
+ image_style_save(array('name' => 'image_test'));
+ $url = image_style_url('image_test', $original_uri);
$path = $this->randomName();
$element = array(
'#theme' => 'image_style',
- '#style_name' => 'test',
+ '#style_name' => 'image_test',
'#uri' => $original_uri,
);
$rendered_element = render($element);
- $expected_result = '';
+ $expected_result = '';
$this->assertEqual($expected_result, $rendered_element, 'theme_image_style() renders an image correctly.');
}