core/modules/responsive_image/responsive_image.module | 10 +++------- .../Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php | 2 +- .../src/Tests/ResponsiveImageFieldDisplayTest.php | 4 ++-- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/core/modules/responsive_image/responsive_image.module b/core/modules/responsive_image/responsive_image.module index b00f981..5f0ff92 100644 --- a/core/modules/responsive_image/responsive_image.module +++ b/core/modules/responsive_image/responsive_image.module @@ -114,8 +114,8 @@ function responsive_image_theme() { * An associative array containing: * - item: An ImageItem object. * - image_style: An optional image style. - * - path: An optional array containing the link 'path' and link 'options'. * - mapping_id: The ID of the responsive image mapping. + * - url: An optional \Drupal\Core\Url object. * * @ingroup themeable */ @@ -149,12 +149,8 @@ function theme_responsive_image_formatter($variables) { if (Unicode::strlen($item->title) != 0) { $responsive_image['#title'] = $item->title; } - // @todo Add support for route names. - if (isset($variables['path']['path'])) { - $path = $variables['path']['path']; - $options = isset($variables['path']['options']) ? $variables['path']['options'] : array(); - $options['html'] = TRUE; - return \Drupal::l($responsive_image, Url::fromUri($path, $options)); + if (isset($variables['url'])) { + return \Drupal::l($responsive_image, $variables['url']->setOption('html', TRUE)); } return drupal_render($responsive_image); diff --git a/core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php b/core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php index 7b940f3..f7eeb19 100644 --- a/core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php +++ b/core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php @@ -179,7 +179,7 @@ public function viewElements(FieldItemListInterface $items) { $url = NULL; // Check if the formatter involves a link. if ($this->getSetting('image_link') == 'content') { - $uri = $items->getEntity()->urlInfo()->toArray(); + $url = $items->getEntity()->urlInfo(); } elseif ($this->getSetting('image_link') == 'file') { $link_file = TRUE; diff --git a/core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php b/core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php index bf27b04..05e559a 100644 --- a/core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php +++ b/core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php @@ -291,7 +291,7 @@ public function testResponsiveImageFieldFormattersLinkToFile() { */ public function testResponsiveImageFieldFormattersLinkToNode() { $this->addTestMappings(); - $this->assertResponsiveImageFieldFormattersLink('node'); + $this->assertResponsiveImageFieldFormattersLink('content'); } /** @@ -334,7 +334,7 @@ private function assertResponsiveImageFieldFormattersLink($link_type) { case 'content': // Make sure the link to the node is present. - $this->assertPattern('/url() . '"(.*?)>assertPattern('/url(), '/') . '"(.*?)>