What cause my 404 error for my user_picture thumbnail in template file? I want to print user_picture thumbnail in my page template. I am using the following code in hook_preprocess_html() in my .theme file.

$user = user_load(\Drupal::currentUser()-&gt;id());
$style = entity_load('image_style', 'thumbnail');
$variables['user_picture'] = $style-&gt;buildUrl($user-&gt;get('user_picture')-&gt;entity-&gt;url());


It's generating a URl but it is showing 404, what could be wrong here?
In hook_preprocess_html() add the following code.

  $user = user_load(\Drupal::currentUser()-&gt;id());;
  $variables['user_pic'] = $user-&gt;user_picture-&gt;entity-&gt;uri-&gt;value;


In your template file use code similar to the following one.

 &lt;img width="62" height="62" class="image-responsive img-circle" src="{{ file_url(user.pic) }}" /&gt;


If you want to apply an image style, use the following code in hook_preprocess_html().

$variables['user_pic'] = ImageStyle::load('thumbnail')-&gt;buildUrl($user-&gt;get('user_pic‌​ture')-&gt;entity-&gt;uri-‌​&gt;value);


In the template file, use the following.

 &lt;img src="{{ user.pic }}" /&gt;