I want to add some to user picture div. Currently it has user-picture class. I am using bootstrap frame work for responsive design. So want to add class col-md-2.

But user-picture.tpl.php has hard coded

<?php if ($user_picture): ?>
  <div class="user-picture">
    <?php print $user_picture; ?>
  </div>
<?php endif; ?>

So my code in my theme template file function template_preprocess_user_picture has no effect.

If I am doing mistake, then please give me guidance.
I am attaching path for it. I have changed line from <div class="user-picture"> to <div class="<?php print $classes; ?>">

CommentFileSizeAuthor
#2 user-picture-tpl-2313085-2.patch384 bytestkuldeep17
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tkuldeep17’s picture

Title: Can't add class to user picture by template_preprocess_user_picture as class attribute has hard coded by user picture tpl file » Can't add class to user picture by template_preprocess_user_picture as class attribute has hard coded in user picture tpl file
tkuldeep17’s picture

Status: Active » Needs review
FileSize
384 bytes
mgifford’s picture

Is this also an issue in D8? It either needs to be fixed there or proven that it isn't required there before it can be brought into D7.

bocaj’s picture

Category: Feature request » Bug report
Status: Needs review » Reviewed & tested by the community

This is definitely an issue in D7. I haven't gotten into D8 enough yet to know if the problem still is present there or not. This patch works as expected.

David_Rothstein’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +7.40 release notes

Hm, clever. I was going to say we can't do this because it removes the existing "user-picture" class, but actually that still winds up getting printed because template_preprocess() adds it as a default class (based on the fact that the theme hook is named "user_picture"). So I think it's all good.

This shouldn't be relevant for Drupal 8 since the user picture is a standard field in Drupal 8.

Committed to 7.x - thanks!

  • David_Rothstein committed ab86fe4 on 7.x
    Issue #2313085 by tkuldeep17: Can't add class to user picture by...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

spencerthayer’s picture

This is annoying. Has this been fixed yet without a patch?