reverted: --- b/core/config/schema/core.data_types.schema.yml +++ a/core/config/schema/core.data_types.schema.yml @@ -181,6 +181,9 @@ name: type: boolean label: 'Site name' + node_user_picture: + type: boolean + label: 'User pictures in posts' slogan: type: boolean label: 'Site slogan' reverted: --- b/core/includes/theme.inc +++ a/core/includes/theme.inc @@ -105,6 +105,7 @@ return array( 'favicon', 'logo', + 'node_user_picture', 'comment_user_picture', 'comment_user_verification', ); reverted: --- b/core/lib/Drupal/Core/Extension/ThemeHandler.php +++ a/core/lib/Drupal/Core/Extension/ThemeHandler.php @@ -20,6 +20,7 @@ protected $defaultFeatures = array( 'favicon', 'logo', + 'node_user_picture', 'comment_user_picture', 'comment_user_verification', ); diff -u b/core/modules/node/node.module b/core/modules/node/node.module --- b/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -131,26 +131,35 @@ * Implements hook_theme(). */ function node_theme() { - return array( - 'node' => array( + return [ + 'node' => [ 'render element' => 'elements', - ), - 'node_add_list' => array( - 'variables' => array('content' => NULL), - ), - 'node_edit_form' => array( + ], + 'node_add_list' => [ + 'variables' => ['content' => NULL], + ], + 'node_edit_form' => [ 'render element' => 'form', - ), - 'field__node__title' => array( + ], + 'field__node__title' => [ 'base hook' => 'field', - ), - 'field__node__uid' => array( + ], + 'field__node__uid' => [ 'base hook' => 'field', - ), - 'field__node__created' => array( + ], + 'field__node__created' => [ 'base hook' => 'field', - ), - ); + ], + 'node_submitted_by' => [ + 'variables' => [ + 'author_picture' => FALSE, + 'author_attributes' => [], + 'author_name' => '', + 'date' => '', + 'metadata' => [], + ], + ], + ]; } /** @@ -367,15 +376,21 @@ * Implements hook_entity_extra_field_info(). */ function node_entity_extra_field_info() { - $extra = array(); + $extra = []; $description = t('Node module element'); foreach (NodeType::loadMultiple() as $bundle) { - $extra['node'][$bundle->id()]['display']['links'] = array( + $extra['node'][$bundle->id()]['display']['links'] = [ 'label' => t('Links'), 'description' => $description, 'weight' => 100, 'visible' => TRUE, - ); + ]; + $extra['node'][$bundle->id()]['display']['submitted_by'] = [ + 'label' => t('Submitted by'), + 'description' => t('Author name and node submission date'), + 'weight' => -4, + 'visible' => $bundle->displaySubmitted(), + ]; } return $extra; @@ -596,6 +611,15 @@ $node_type = $node->type->entity; // Used by RDF to add attributes around the author and date submitted. $variables['author_attributes'] = new Attribute(); + $variables['display_submitted'] = $node_type->displaySubmitted(); + if ($variables['display_submitted']) { + if (theme_get_setting('features.node_user_picture')) { + // To change user picture settings (e.g. image style), edit the 'compact' + // view mode on the User entity. Note that the 'compact' view mode might + // not be configured, so remember to always check the theme setting first. + $variables['author_picture'] = user_view($node->getOwner(), 'compact'); + } + } // Add article ARIA role. $variables['attributes']['role'] = 'article'; reverted: --- b/core/modules/system/config/install/system.theme.global.yml +++ a/core/modules/system/config/install/system.theme.global.yml @@ -7,6 +7,7 @@ comment_user_picture: true comment_user_verification: true favicon: true + node_user_picture: true logo: path: '' url: '' diff -u b/core/modules/system/src/Form/ThemeSettingsForm.php b/core/modules/system/src/Form/ThemeSettingsForm.php --- b/core/modules/system/src/Form/ThemeSettingsForm.php +++ b/core/modules/system/src/Form/ThemeSettingsForm.php @@ -132,7 +132,10 @@ ); // Toggle settings + // The node_user_picture setting should be deprecated in Drupal 9.x + // in favour of the "Authored by" field in the manage display tab. $toggles = array( + 'node_user_picture' => t('User pictures in posts'), 'comment_user_picture' => t('User pictures in comments'), 'comment_user_verification' => t('User verification status in comments'), 'favicon' => t('Shortcut icon'), reverted: --- b/core/modules/user/src/Tests/UserPictureTest.php +++ a/core/modules/user/src/Tests/UserPictureTest.php @@ -90,14 +90,22 @@ $node = $this->drupalCreateNode(array('type' => 'article')); + // Enable user pictures on nodes. + $this->config('system.theme.global')->set('features.node_user_picture', TRUE)->save(); + - // Get the user picture image style name. $image_style_id = $this->config('core.entity_view_display.user.user.compact')->get('content.user_picture.settings.image_style'); $style = ImageStyle::load($image_style_id); $image_url = file_url_transform_relative($style->buildUrl($file->getfileUri())); $alt_text = 'Profile picture for user ' . $this->webUser->getUsername(); + // Verify that the image is displayed on the node page. + $this->drupalGet('node/' . $node->id()); + $elements = $this->cssSelect('.node__meta .field--name-user-picture img[alt="' . $alt_text . '"][src="' . $image_url . '"]'); + $this->assertEqual(count($elements), 1, 'User picture with alt text found on node page.'); + + // Enable user pictures on comments, instead of nodes. - // Enable user pictures on comments. $this->config('system.theme.global') + ->set('features.node_user_picture', FALSE) ->set('features.comment_user_picture', TRUE) ->save(); @@ -108,8 +116,9 @@ $elements = $this->cssSelect('.comment__meta .field--name-user-picture img[alt="' . $alt_text . '"][src="' . $image_url . '"]'); $this->assertEqual(count($elements), 1, 'User picture with alt text found on the comment.'); + // Disable user pictures on comments and nodes. - // Disable user pictures on comments. $this->config('system.theme.global') + ->set('features.node_user_picture', FALSE) ->set('features.comment_user_picture', FALSE) ->save(); reverted: --- b/core/profiles/minimal/minimal.install +++ a/core/profiles/minimal/minimal.install @@ -12,6 +12,9 @@ * @see system_install() */ function minimal_install() { + // Disable the user pictures on nodes. + \Drupal::configFactory()->getEditable('system.theme.global')->set('features.node_user_picture', FALSE)->save(TRUE); + // Allow visitor account creation, but with administrative approval. \Drupal::configFactory()->getEditable('user.settings')->set('register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)->save(TRUE); } only in patch2: unchanged: --- a/core/modules/node/src/NodeViewBuilder.php +++ b/core/modules/node/src/NodeViewBuilder.php @@ -2,6 +2,7 @@ namespace Drupal\node; +use Drupal\Core\Template\Attribute; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityViewBuilder; @@ -38,6 +39,18 @@ public function buildComponents(array &$build, array $entities, array $displays, ); } + if ($display->getComponent('submitted_by')) { + $build[$id]['submitted_by'] = [ + '#theme' => 'node_submitted_by', + '#author_name' => drupal_render($build[$id]['uid']), + '#date' => drupal_render($build[$id]['created']), + '#author_attributes' => new Attribute(), + ]; + if (theme_get_setting('features.node_user_picture')) { + $build[$id]['submitted_by']['#author_picture'] = user_view($entity->getOwner(), 'compact'); + } + } + // Add Language field text element to node render array. if ($display->getComponent('langcode')) { $build[$id]['langcode'] = array( only in patch2: unchanged: --- /dev/null +++ b/core/modules/node/templates/node-submitted-by.html.twig @@ -0,0 +1,27 @@ +{# +/** + * @file + * Default theme implementation for the node created field. + * + * This is an override of field.html.twig for the node created field. See that + * template for documentation about its details and overrides. + * + * Available variables: + * - author_picture: . + * - author_attributes: . + * - author_name: . + * - date: . + * - metadata: . + * + * @see field.html.twig + * + * @ingroup themeable + */ +#} +