diff --git a/core/modules/media/media.module b/core/modules/media/media.module index 8a9101c..488d981 100644 --- a/core/modules/media/media.module +++ b/core/modules/media/media.module @@ -27,8 +27,8 @@ function media_help($route_name, RouteMatchInterface $route_match) { $output .= '
' . t('Creating media items') . '
'; $output .= '
' . t('When a new media item is created, the Media module records basic information about it, including the author, date of creation, and the media type. It also manages the publishing options, which define whether or not the item is published. Default settings can be configured for each type of media on your site.', [':media-type' => Url::fromRoute('entity.media_type.collection')->toString()]) . '
'; $output .= '
' . t('Listing media items') . '
'; - $output .= '
' . t('Media items are listed at Content > Media.', [ - ':media-collection' => Url::fromUri('internal:/admin/content/media'), + $output .= '
' . t('Media items are listed at The media administration page.', [ + ':media-collection' => Url::fromUri('internal:/admin/content/media')->toString(), ]) . '
'; $output .= '
' . t('Creating custom media types') . '
'; $output .= '
' . t('The Media module gives users with the Administer media types permission the ability to create new media types in addition to the default ones already configured. Each media type has an associated media source (such as the image source) which support thumbnail generation and metadata extraction. Fields managed by the Field module may be added for storing that metadata, such as width and height, as well as any other associated values.', [ @@ -146,12 +146,12 @@ function media_form_field_ui_field_storage_add_form_alter(&$form, FormStateInter // File, or Image reference field. $description_text = t('Use Media reference fields for most files, images, audio, videos, and remote media. Use File or Image reference fields when creating your own media types, or for legacy files and images created before enabling the Media module.'); if (\Drupal::moduleHandler()->moduleExists('help')) { - $description_text .= '
' . t('You can find more information about the difference between them on the help page.', [ + $description_text .= '
' . t('For more information, see the Media help page.', [ '@help_url' => Url::fromRoute('help.page', ['name' => 'media'])->toString(), ]); } else { - $description_text .= '
' . t('To learn more about the difference, please install the Help module and visit the media help page (/admin/help/media).'); + $description_text .= '
' . t('For more information, install the Help module and see the Media help page (/admin/help/media).'); } $form['add']['description_wrapper'] = [ '#type' => 'container', diff --git a/core/modules/media/tests/src/FunctionalJavascript/MediaReferenceFieldHelpTest.php b/core/modules/media/tests/src/FunctionalJavascript/MediaReferenceFieldHelpTest.php new file mode 100644 index 0000000..85a3992 --- /dev/null +++ b/core/modules/media/tests/src/FunctionalJavascript/MediaReferenceFieldHelpTest.php @@ -0,0 +1,56 @@ +assertSession(); + $page = $this->getSession()->getPage(); + + $type = $this->drupalCreateContentType([ + 'type' => 'foo', + ]); + $this->drupalGet("/admin/structure/types/manage/{$type->id()}/fields/add-field"); + + $field_types = [ + 'file', + 'image', + 'field_ui:entity_reference:media', + ]; + $description_ids = array_map(function ($item) { + return '#edit-description-' . Html::cleanCssIdentifier($item); + }, $field_types); + + // Choose a boolean field, none of the description containers should be + // visible. + $assert_session->optionExists('edit-new-storage-type', 'boolean'); + $page->selectFieldOption('edit-new-storage-type', 'boolean'); + foreach ($description_ids as $description_id) { + $this->assertFalse($assert_session->elementExists('css', $description_id)->isVisible()); + } + // Select each of the file, image, and media fields and verify their + // descriptions are now visible and match the expected text. + $help_text = 'Use Media reference fields for most files, images, audio, videos, and remote media. Use File or Image reference fields when creating your own media types, or for legacy files and images created before enabling the Media module.For more information, install the Help module and see the Media help page (/admin/help/media).'; + foreach ($field_types as $field_name) { + $assert_session->optionExists('edit-new-storage-type', $field_name); + $page->selectFieldOption('edit-new-storage-type', $field_name); + $field_description_element = $assert_session->elementExists('css', '#edit-description-' . Html::cleanCssIdentifier($field_name)); + $this->assertTrue($field_description_element->isVisible()); + $this->assertEquals($help_text, $field_description_element->getText()); + } + } + +}