How to override user_picture per comment? I use the facebook connect plugin. By default it downloads the 50x50 pixel facebook image. It luckily stores it as the profile ID, which I can in turn use to look up the large version of the image. So I need way to:


Get the current user_picture for a comment, and then
Override it with a new url.


I have this so far:

function capewinefarms_preprocess_comment(&amp;$variables) 
{
    $comment = $variables['elements']['#comment'];
    $variables['comment_create_date'] = format_date($comment-&gt;created-&gt;value, "custom", "d M Y, H:i:s");

    $variables['user_picture'] =  'BLA';
}


The above code replaces the user's profile pic with the words "BLA". But I don't want that. So I need a way to see what the variables object looks like, so I can see where to get the current value and to change it. But if I do this:

print_r($variables);


It just bombs out and shows a blank screen (as if the variable is blank).

How do I change the user picture?
A dump of the $variables array is probably causing out-of-memory problems as preprocess variables in D8 can have some heavy depth to them.

Anyway, you can retrieve the image url from $user_picture render array which has a reference to the comment's user:

  $comment_user = $variables['user_picture']['#user'];
  if ($user_image = $comment_user-&gt;user_picture-&gt;first()) {
    $user_image_uri = $user_image-&gt;entity-&gt;uri-&gt;value;
  }