diff --git a/core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php b/core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php index f3a2084aa57efe67183babff1bb23f5ce656cfc1..f585bc240a38af148a7eb8a06af880d35c1387d9 100644 --- a/core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php +++ b/core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php @@ -112,6 +112,7 @@ public function addImageStyleMapping($breakpoint_id, $multiplier, array $image_s 'breakpoint_id' => $breakpoint_id, 'multiplier' => $multiplier, ) + $image_style_mapping; + $this->keyedImageStyleMappings = NULL; return $this; } } diff --git a/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php b/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php index 63580a87203fd19489256ab50b9d0880ccbff041..71e81edcec0eab545459c553889dd9907b4486b6 100644 --- a/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php +++ b/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php @@ -252,6 +252,19 @@ public function testGetKeyedImageStyleMappings() { 'image_mapping' => 'medium', ); $this->assertEquals($expected, $entity->getKeyedImageStyleMappings()); + + // Overwrite a mapping to ensure keyed mapping static cache is rebuilt. + $entity->addImageStyleMapping('test_breakpoint2', '2x', array( + 'image_mapping_type' => 'image_style', + 'image_mapping' => 'large', + )); + $expected['test_breakpoint2']['2x'] = array( + 'breakpoint_id' => 'test_breakpoint2', + 'multiplier' => '2x', + 'image_mapping_type' => 'image_style', + 'image_mapping' => 'large', + ); + $this->assertEquals($expected, $entity->getKeyedImageStyleMappings()); } /**