diff --git a/core/modules/media_library/media_library.module b/core/modules/media_library/media_library.module index 19ef3c2131d7f89c6cba50b2d207d48bacad980c..5312b8e96dbe7404aefd7a029fc79086eef6252a 100644 --- a/core/modules/media_library/media_library.module +++ b/core/modules/media_library/media_library.module @@ -402,8 +402,7 @@ function _media_library_configure_form_display(MediaTypeInterface $type) { $display->removeComponent($name); } // Expose the name field when it is not mapped. - $field_map = $type->getFieldMap(); - if (empty($field_map['name'])) { + if (!in_array('name', $type->getFieldMap(), TRUE)) { $display->setComponent('name', [ 'type' => 'string_textfield', 'settings' => [ diff --git a/core/modules/media_library/tests/src/Functional/MediaLibraryDisplayModeTest.php b/core/modules/media_library/tests/src/Functional/MediaLibraryDisplayModeTest.php index 47023f88d110ca798341625d0628dc7f413de295..2d4c056f345eb1275e0365c365b0eeaf77587354 100644 --- a/core/modules/media_library/tests/src/Functional/MediaLibraryDisplayModeTest.php +++ b/core/modules/media_library/tests/src/Functional/MediaLibraryDisplayModeTest.php @@ -162,6 +162,22 @@ public function testDisplayModes() { $this->assertFormDisplay($type_eight_id, FALSE, TRUE); $this->assertViewDisplay($type_eight_id, 'medium'); + // Create an oEmbed media type with a mapped name field in the UI. + $type_id = 'pinto_bean'; + $edit = [ + 'label' => $type_id, + 'id' => $type_id, + 'source' => 'oembed:video', + ]; + $this->drupalPostForm('admin/structure/media/add', $edit, 'Save'); + $edit = [ + 'field_map[title]' => 'name', + ]; + $this->drupalPostForm(NULL, $edit, t('Save')); + $this->assertSession()->pageTextContains("Media Library form and view displays have been created for the $type_id media type."); + $this->assertFormDisplay($type_id, FALSE, FALSE); + $this->assertViewDisplay($type_id, 'medium'); + // Delete a form and view display. EntityFormDisplay::load('media.type_one.media_library')->delete(); EntityViewDisplay::load('media.type_one.media_library')->delete();