diff --git a/core/modules/media/templates/media.html.twig b/core/modules/media/templates/media.html.twig index 41731992ec..805f61ac70 100644 --- a/core/modules/media/templates/media.html.twig +++ b/core/modules/media/templates/media.html.twig @@ -37,12 +37,11 @@ page title, so we do not display it here. #} {{ title_prefix }} - {% if label and view_mode != 'full' %} + {% if name and view_mode != 'full' %} - {{ label }} + {{ name }} {% endif %} {{ title_suffix }} - {{ content }} diff --git a/core/modules/media/tests/src/Functional/MediaContextualLinksTest.php b/core/modules/media/tests/src/Functional/MediaContextualLinksTest.php new file mode 100644 index 0000000000..1d97773143 --- /dev/null +++ b/core/modules/media/tests/src/Functional/MediaContextualLinksTest.php @@ -0,0 +1,45 @@ +createMediaType(); + + // Create a media item. + $media = Media::create([ + 'bundle' => $mediaType->id(), + 'name' => 'Unnamed', + ]); + $media->save(); + + $user = $this->drupalCreateUser([ + 'administer media', + 'access contextual links', + ]); + $this->drupalLogin($user); + + $this->drupalGet('media/' . $media->id()); + $this->assertSession()->elementAttributeContains('css', 'div[data-contextual-id]', 'data-contextual-id', 'media:media=' . $media->id() . ':'); + } + +} diff --git a/core/themes/classy/templates/content/media.html.twig b/core/themes/classy/templates/content/media.html.twig index f36975cb9a..cd263e0afe 100644 --- a/core/themes/classy/templates/content/media.html.twig +++ b/core/themes/classy/templates/content/media.html.twig @@ -20,8 +20,14 @@ view_mode ? 'media--view-mode-' ~ view_mode.id()|clean_class, ] %} + - {% if content %} - {{ content }} + {{ title_prefix }} + {% if name and view_mode != 'full' %} + + {{ name }} + {% endif %} + {{ title_suffix }} + {{ content }} diff --git a/core/themes/stable/templates/content/media.html.twig b/core/themes/stable/templates/content/media.html.twig index 769b7be751..e71bd968b6 100644 --- a/core/themes/stable/templates/content/media.html.twig +++ b/core/themes/stable/templates/content/media.html.twig @@ -13,7 +13,11 @@ */ #} - {% if content %} - {{ content }} + {% if name and view_mode != 'full' %} + + {{ name }} + {% endif %} + {{ title_suffix }} + {{ content }}