I want to show the user picture on the search page. Currently only its show the user email or name, but I want to show the user profile picture.

How can I do that?

Note: the search page is about the user type, so when I search some users their picture should be displayed on the search result page.

  • Not able to understand which type of content you searching on search page
    – user52318
    Commented Jan 15, 2016 at 10:42
  • user type when i am search some user its picture should be display on search result page Commented Jan 15, 2016 at 10:46
  • midwesternmac.com/blogs/jeff-geerling/… go through this article hope so it may help you .
    – user52318
    Commented Jan 15, 2016 at 13:41

1 Answer 1


Copy the file YOUR_SITE/modules/search/search-result.tpl.php to your theme and modify the code inside with this:

//obtaining the username
$username = explode('(', $title);
$username = trim($username[0]);
//getting the user object
$user = user_load_by_name($username);
<li class="<?php print $classes; ?>"<?php print $attributes; ?>>
  <?php print render($title_prefix); ?>

   * The following line will print the user picture
  print theme('user_picture', array('account' =>$user));

  <h3 class="title"<?php print $title_attributes; ?>>
    <a href="<?php print $url; ?>"><?php print $title; ?></a>
  <?php print render($title_suffix); ?>
  <div class="search-snippet-info">
    <?php if ($snippet): ?>
      <p class="search-snippet"<?php print $content_attributes; ?>><?php print $snippet; ?></p>
    <?php endif; ?>
    <?php if ($info): ?>
      <p class="search-info"><?php print $info; ?></p>
    <?php endif; ?>

This will be the output:

enter image description here

EDIT: If you want follow another way you can read this: How to access to the user info on the search page?

  • if we show user first name or last name field then how can i do that Commented Jan 18, 2016 at 5:41
  • Which order of fields you want? Commented Jan 18, 2016 at 12:57
  • Like our other field city name or may be country name Commented Jan 18, 2016 at 12:58
  • @AdeelNawaz I can't understand what are you trying to do, post another question with more information please. And let me know Commented Jan 18, 2016 at 13:00
  • check this drupal.stackexchange.com/questions/187171/… Commented Jan 18, 2016 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.