diff --git a/core/modules/picture/lib/Drupal/picture/Tests/PictureThemeFunctionsTest.php b/core/modules/picture/lib/Drupal/picture/Tests/PictureThemeFunctionsTest.php deleted file mode 100644 index 201a6e6..0000000 --- a/core/modules/picture/lib/Drupal/picture/Tests/PictureThemeFunctionsTest.php +++ /dev/null @@ -1,113 +0,0 @@ - 'Picture theme functions', - 'description' => 'Tests the picture theme functions.', - 'group' => 'Picture', - ); - } - - /** - * Tests usage of the template_preprocess_picture() function. - */ - function testPictureTheme() { - // Create an image. - $files = $this->drupalGetTestFiles('image'); - $file = reset($files); - $original_uri = file_unmanaged_copy($file->uri, 'public://', FILE_EXISTS_RENAME); - - // Create a style. - $style = entity_create('image_style', array('name' => 'test', 'label' => 'Test')); - $style->save(); - $url = $style->buildUrl($original_uri); - - // Test using template_preprocess_picture() with a NULL value for the alt option. - $element = array( - '#theme' => 'picture', - '#uri' => $original_uri, - '#alt' => NULL, - '#style_name' => 'test', - ); - $rendered_element = render($element); - $this->assertTrue(strpos($rendered_element, '') !== FALSE, 'picture element in template_preprocess_picture() correctly renders with a NULL value for the alt option.'); - - // Test using template_preprocess_picture() without passing a value for the alt option. - unset($element['#alt']); - $rendered_element = render($element); - $expected_result = ''; - $this->assertTrue(strpos($rendered_element, $expected_result) !== FALSE, 'img element in template_preprocess_picture() correctly renders the alt option.'); - $this->assertTrue(strpos($rendered_element, '') !== FALSE, 'picture1 element in template_preprocess_picture() correctly renders the alt option.'); - } - - /** - * Tests usage of the theme_picture_formatter() function. - */ - function testPictureFormatterTheme() { - // Create an image. - $files = $this->drupalGetTestFiles('image'); - $file = reset($files); - $original_uri = file_unmanaged_copy($file->uri, 'public://', FILE_EXISTS_RENAME); - - // Create a style. - $style = entity_create('image_style', array('name' => 'test', 'label' => 'Test')); - $style->save(); - $url = $style->buildUrl($original_uri); - - // Test using theme_picture_formatter() without breakpoints and with a NULL value for the alt option. - $path = $this->randomName(); - $element = array( - '#theme' => 'picture_formatter', - '#item' => array( - 'uri' => $original_uri, - 'alt' => NULL, - ), - '#image_style' => 'test', - '#path' => array( - 'path' => $path, - ), - );$expected_result = ''; - $rendered_element = render($element); - $expected_result = ''; - $this->assertEqual($expected_result, $rendered_element, 'theme_picture_formatter() correctly renders without breakpoints and with a NULL value for the alt option.'); - - // Test using theme_picture_formatter() without an image title, alt text, or - // link options. - unset($element['#item']['alt']); - $rendered_element = render($element); - $expected_result = ''; - $this->assertEqual($expected_result, $rendered_element, 'theme_picture_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(); - $element['#path']['path'] = ''; - $element['#path']['options'] = array( - 'external' => TRUE, - 'fragment' => $fragment, - ); - $rendered_element = render($element); - $expected_result = ''; - $this->assertEqual($expected_result, $rendered_element, 'theme_picture_formatter() correctly renders a link fragment.'); - } -} diff --git a/core/modules/picture/templates/picture.html.twig b/core/modules/picture/templates/picture.html.twig deleted file mode 100644 index bbd8ef9..0000000 --- a/core/modules/picture/templates/picture.html.twig +++ /dev/null @@ -1,26 +0,0 @@ -{# -/** - * @file - * Default theme implementation to display a picture tag. - * - * Available variables: - * - attributes: HTML attributes for the picture tag. - * - sources: A set of source data. - * - source.attributes: HTML attributes for each source tag. - * - fallback: Fallback image tag for non-JS browsers. - * - * @see template_preprocess_picture() - * - * @ingroup themeable - */ -#} -{% if sources %} - - {% for source in sources %} - - {% endfor %} - - -{% else %} - {{- fallback -}} -{% endif %} diff --git a/core/modules/responsive_image/responsive_image.module b/core/modules/responsive_image/responsive_image.module index 79f0a97..7cd2be3 100644 --- a/core/modules/responsive_image/responsive_image.module +++ b/core/modules/responsive_image/responsive_image.module @@ -125,7 +125,6 @@ function responsive_image_theme() { /** * Returns HTML for a responsive image. * Prepares variables for picture templates. - * Returns HTML for a picture. * Default template: picture.html.twig. * * @param $variables @@ -142,7 +141,7 @@ function responsive_image_theme() { * - style_name: The name of the style to be used to alter the original image. */ -function template_preprocess_picture(&$variables) { +function template_preprocess_responsive_image(&$variables) { // Make sure that width and height are proper values // If they exists we'll output them // @see http://www.w3.org/community/respimg/2012/06/18/florians-compromise/ @@ -238,6 +237,7 @@ function template_preprocess_picture(&$variables) { '#uri' => $variables['uri'], '#width' => $variables['width'], '#height' => $variables['height'], + '#alt' => isset($variables['alt']) || array_key_exists('alt', $variables) ? $variables['alt'] : NULL, '#title' => isset($variables['title']) ? $variables['title'] : NULL, ); }