diff -u b/core/modules/picture/lib/Drupal/picture/Entity/PictureMapping.php b/core/modules/picture/lib/Drupal/picture/Entity/PictureMapping.php --- b/core/modules/picture/lib/Drupal/picture/Entity/PictureMapping.php +++ b/core/modules/picture/lib/Drupal/picture/Entity/PictureMapping.php @@ -95,23 +95,16 @@ if (isset($this->breakpointGroup) && is_object($this->breakpointGroup)) { $this->breakpointGroup = $this->breakpointGroup->id(); } + // Split the breakpoint ids into their different parts, as dots as // identifiers are not possible. $loaded_mappings = $this->mappings; $this->mappings = array(); foreach ($loaded_mappings as $breakpoint_id => $mapping) { - $map = &$this->mappings; - foreach (explode('.', $breakpoint_id) as $id) { - if (!is_array($map)) { - $map = array(); - } - elseif (!isset($map[$id])) { - $map[$id] = array(); - } - $map = &$map[$id]; - } - $map = $mapping; + list($source_type, $source, $name) = explode('.', $breakpoint_id); + $this->mappings[$source_type][$source][$name] = $mapping; } + parent::save(); $this->loadBreakpointGroup(); $this->loadAllMappings(); @@ -146,21 +139,14 @@ $this->mappings = array(); if ($this->breakpointGroup) { foreach ($this->breakpointGroup->getBreakpoints() as $breakpoint_id => $breakpoint) { - // Get the mapping for this breakpoint id. - $mapping = &$loaded_mappings; - foreach (explode('.', $breakpoint_id) as $id) { - if (isset($mapping[$id])) { - $mapping = &$mapping[$id]; - } - else { - $mapping = array(); - break; - } - } + // Get the components of the breakpoint id to match the format of the + // configuration file. + list($source_type, $source, $name) = explode('.', $breakpoint_id); + // Get the mapping for the default multiplier. $this->mappings[$breakpoint_id]['1x'] = ''; - if (isset($mapping['1x'])) { - $this->mappings[$breakpoint_id]['1x'] = $mapping['1x']; + if (isset($loaded_mappings[$source_type][$source][$name]['1x'])) { + $this->mappings[$breakpoint_id]['1x'] = $loaded_mappings[$source_type][$source][$name]['1x']; } // Get the mapping for the other multipliers. @@ -168,8 +154,8 @@ foreach ($breakpoint->multipliers as $multiplier => $status) { if ($status) { $this->mappings[$breakpoint_id][$multiplier] = ''; - if (isset($mapping[$multiplier])) { - $this->mappings[$breakpoint_id][$multiplier] = $mapping[$multiplier]; + if (isset($loaded_mappings[$source_type][$source][$name][$multiplier])) { + $this->mappings[$breakpoint_id][$multiplier] = $loaded_mappings[$source_type][$source][$name][$multiplier]; } } }