diff --git a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageUrlFormatter.php b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageUrlFormatter.php index f0ce6c6..1a633f8 100644 --- a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageUrlFormatter.php +++ b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageUrlFormatter.php @@ -92,13 +92,10 @@ public function viewElements(FieldItemListInterface $items) { $image_style_setting = $this->getSetting('image_style'); - // Collect cache tags to be added for each item in the field. - $image_style_cache_tags = []; /** @var \Drupal\image\Entity\ImageStyle|false $image_style */ $image_style = FALSE; if (!empty($image_style_setting)) { $image_style = $this->imageStyleStorage->load($image_style_setting); - $image_style_cache_tags = $image_style->getCacheTags(); } foreach ($images as $delta => $image) { @@ -108,7 +105,10 @@ public function viewElements(FieldItemListInterface $items) { ? $image_style->buildUrl($image_uri) : file_create_url($image_uri); - $cache_tags = Cache::mergeTags($image_style_cache_tags, $image->getCacheTags()); + // Collect cache tags to be added for each item in the field. + $cache_tags = $image_style + ? Cache::mergeTags($image_style->getCacheTags(), $image->getCacheTags()) + : $image->getCacheTags(); $elements[$delta] = [ '#markup' => $url,