diff --git a/core/lib/Drupal/Core/Entity/EntityRenderController.php b/core/lib/Drupal/Core/Entity/EntityRenderController.php index 2cd0578..0bd821a 100644 --- a/core/lib/Drupal/Core/Entity/EntityRenderController.php +++ b/core/lib/Drupal/Core/Entity/EntityRenderController.php @@ -66,6 +66,23 @@ public function buildContent(array $entities = array(), $view_mode = 'full', $la } /** + * Implements Drupal\Core\Entity\EntityRenderControllerInterface::buildUserPictures(). + */ + function buildUserPictures(array $entities = array(), $view_mode = 'compact', $langcode = NULL) { + $accounts = array(); + foreach ($entities as $entity) { + $accounts[$entity->account->id()] = $entity->account; + } + if (!empty($accounts)) { + $rendered_accounts = user_view_multiple($accounts, 'compact'); + foreach ($entities as $entity_id => $entity) { + // @todo Should we need to declare user_picture property in Entity? + $entities[$entity_id]->content['user_picture'] = $rendered_accounts[$entity->account->id()]; + } + } + } + + /** * Provides entity-specific defaults to the build process. * * @param Drupal\Core\Entity\EntityInterface $entity diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index ab757a9..28030fc 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1654,14 +1654,6 @@ function template_preprocess_comment(&$variables) { $variables['changed'] = format_date($comment->changed); $variables['new'] = !empty($comment->new) ? t('new') : ''; - if (theme_get_setting('toggle_comment_user_picture')) { - // To change user picture settings (e.g., image style), edit the 'compact' - // view mode on the User entity. - $variables['user_picture'] = user_view($comment->account, 'compact'); - } - else { - $variables['user_picture'] = array(); - } $variables['signature'] = $comment->signature; $uri = $comment->uri(); diff --git a/core/modules/comment/lib/Drupal/comment/CommentRenderController.php b/core/modules/comment/lib/Drupal/comment/CommentRenderController.php index bc21cd2..d105f1a 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentRenderController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentRenderController.php @@ -32,6 +32,10 @@ public function buildContent(array $entities = array(), $view_mode = 'full', $la parent::buildContent($entities, $view_mode, $langcode); + if (theme_get_setting('toggle_comment_user_picture') && user_picture_enabled()) { + parent::buildUserPictures($entities, 'compact', $langcode); + } + foreach ($entities as $entity) { $node = node_load($entity->nid); if (!$node) { diff --git a/core/modules/comment/templates/comment.tpl.php b/core/modules/comment/templates/comment.tpl.php index 5a8a37e..4765169 100644 --- a/core/modules/comment/templates/comment.tpl.php +++ b/core/modules/comment/templates/comment.tpl.php @@ -20,8 +20,6 @@ * - $permalink: Comment permalink. * - $submitted: Submission information created from $author and $created during * template_preprocess_comment(). - * - $user_picture: The comment author's picture. Use render($user_picture) to - * print it. * - $signature: Authors signature. * - $status: Comment status. Possible values are: * unpublished, published, or preview. @@ -80,7 +78,7 @@