/**
* {@inheritdoc}
*/
public function onDependencyRemoval(array
$dependencies) { $changed = parent::
onDependencyRemoval($dependencies);
$style_id =
$this->
getSetting('preview_image_style'
);
/** @var \Drupal\image\ImageStyleInterface $style */
if ($style_id &&
$style = ImageStyle::
load($style_id)) { if (!
empty($dependencies[$style->
getConfigDependencyKey()][$style->
getConfigDependencyName()])) { /** @var \Drupal\image\ImageStyleStorageInterface $storage */
$storage = \Drupal::
entityTypeManager()->
getStorage($style->
getEntityTypeId());
$replacement_id =
$storage->
getReplacementId($style_id);
// If a valid replacement has been provided in the storage, replace the
// preview image style with the replacement.
if ($replacement_id && ImageStyle::
load($replacement_id)) { $this->
setSetting('preview_image_style',
$replacement_id);
} // If there's no replacement or the replacement is invalid, disable the
// image preview.
else { $this->
setSetting('preview_image_style', ''
);
} // Signal that the formatter plugin settings were updated.