0

How do I customise the HTML output for the user picture on a user profile? I can output it in user-profile.tpl.php with <?php print $user_profile['user_picture']['#markup'];?>. However this still leaves the original user picture output there too. How do I remove this? The answer in Disable displaying user picture in page--user.tpl.php won't work as that deletes $user_profile['user_picture'], which I'm using.

For an example of this, see http://dev.effectivealtruismhub.com/user/tom-ash . The top, left-floated image is the one I've manually output with <?php print $user_profile['user_picture']['#markup'];?>. But the right floated one is the one that Drupal auto-generates, in the wrong place in the HTML to be positioned right. How can I remove this auto-generated HTML?

  • Try to take a look at admin/config/people/accounts/display and see where user image is (display or hidden) – pbonnefoi Nov 6 '14 at 10:08
  • @pbonnefoi: I already looked there; the Drupal user picture isn't shown on that page, only the Profile2 profiles that I'm using. – tog22 Nov 7 '14 at 12:51
4

Hmmm, it sounds like you likely left the following line of code in user-profile-tpl.php:

<?php print render($user_profile); ?>

Remove the above line of code.

The duplicate image will go away. And so will anything else in the profile.

You'll need to add back each individual item that you actually want via the same method you used to add just the pic, but for other fields in the profile:

<?php print $user_profile['user_picture']['#markup'];?>

If you are using the Panels module, this is trivial to do without touching any code or needing to dive into the $user_profile array.

  • Thanks! Yes, I have <?php print render($user_profile); ?> left in. So do I need to write code which reconstructs the whole output of that except the user picture? Do you know of a tutorial or guide to reconstructing it? – tog22 Nov 7 '14 at 13:00
  • 1. Make sure you have Devel module installed and turned on. 2. Go to /user. 3. Click "Devel" tab. 4. Click "Render" tab. That should get you to a page which lists all the different stuff you can output selectively using $user_profile in user-profile.tpl.php. – Shai Nov 7 '14 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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