diff --git a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php index c8e0e23..294c561 100644 --- a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php +++ b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php @@ -211,8 +211,8 @@ public function viewElements(FieldItemListInterface $items) { if (isset($link_file)) { $image_uri = $file->getFileUri(); $url = Url::fromUri(file_create_url($image_uri)); - $cache_tags = Cache::mergeTags($cache_tags, $file->getCacheTags()); } + $cache_tags = Cache::mergeTags($cache_tags, $file->getCacheTags()); // Extract field item attributes for the theme function, and unset them // from the $item so that the field template does not re-render them. diff --git a/core/modules/image/src/Tests/ImageFieldDisplayTest.php b/core/modules/image/src/Tests/ImageFieldDisplayTest.php index de41118..4750696 100644 --- a/core/modules/image/src/Tests/ImageFieldDisplayTest.php +++ b/core/modules/image/src/Tests/ImageFieldDisplayTest.php @@ -125,7 +125,6 @@ function _testImageFieldFormatters($scheme) { ); $default_output = '' . drupal_render($image) . ''; $this->drupalGet('node/' . $nid); - $this->assertCacheTag($file->getCacheTags()[0]); $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags'); $this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.'); @@ -158,7 +157,7 @@ function _testImageFieldFormatters($scheme) { '#height' => 20, ); $this->drupalGet('node/' . $nid); - $this->assertNoCacheTag($file->getCacheTags()[0]); + $this->assertCacheTag($file->getCacheTags()[0]); $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags'); $this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.'); $elements = $this->xpath( @@ -368,7 +367,7 @@ function testImageFieldDefaultImage() { ); $default_output = str_replace("\n", NULL, drupal_render($image)); $this->drupalGet('node/' . $node->id()); - $this->assertNoCacheTag($file->getCacheTags()[0]); + $this->assertCacheTag($file->getCacheTags()[0]); $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags'); $this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.'); $this->assertRaw($default_output, 'Default image displayed when no user supplied image is present.'); @@ -392,7 +391,7 @@ function testImageFieldDefaultImage() { ); $image_output = str_replace("\n", NULL, drupal_render($image)); $this->drupalGet('node/' . $nid); - $this->assertNoCacheTag($file->getCacheTags()[0]); + $this->assertCacheTag($file->getCacheTags()[0]); $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags'); $this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.'); $this->assertNoRaw($default_output, 'Default image is not displayed when user supplied image is present.'); @@ -440,7 +439,7 @@ function testImageFieldDefaultImage() { ); $default_output = str_replace("\n", NULL, drupal_render($image)); $this->drupalGet('node/' . $node->id()); - $this->assertNoCacheTag($file->getCacheTags()[0]); + $this->assertCacheTag($file->getCacheTags()[0]); $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags'); $this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.'); $this->assertRaw($default_output, 'Default private image displayed when no user supplied image is present.');