diff --git a/core/modules/media_library/src/Form/AddFormBase.php b/core/modules/media_library/src/Form/AddFormBase.php index a3975be376..dc1a78a6ab 100644 --- a/core/modules/media_library/src/Form/AddFormBase.php +++ b/core/modules/media_library/src/Form/AddFormBase.php @@ -785,7 +785,7 @@ protected function getSourceFieldName(MediaTypeInterface $media_type) { * An array containing the pre-selected media items keyed by ID. */ protected function getPreSelectedMediaItems(FormStateInterface $form_state) { - // Get the current select from the form state. + // Get the current selection from the form state. // @see ::processInputValues() $media_ids = $form_state->get('current_selection'); if (!$media_ids) { @@ -820,7 +820,7 @@ protected function getAddedMediaItems(FormStateInterface $form_state) { */ protected function getCurrentMediaItems(FormStateInterface $form_state) { $pre_selected_media = $this->getPreSelectedMediaItems($form_state); - $added_media = $form_state->get('media') ?: []; + $added_media = $this->getAddedMediaItems($form_state); // Using array_merge will renumber the numeric keys. return array_merge($pre_selected_media, $added_media); }