If user pictures are enabled but no default is set and the user has not uploaded a user picture, $picture can print and empty div;

<div class="picture"> </div>

This is problematic because if .picture has layout applied to it such as float: left the proceeding element will wrap one line—e.g. if it's a paragraph it will appear to be indented. Moreover this makes it impossible to test if $picture is empty, e.g. if you wanted to set a conditional class in a template.

This patch applies to user-picture.tpl.php and simply tests if $picture is empty.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch failed testing.

Jeff Burnz’s picture

FileSize
594 bytes

Ok, lets try that again.

Jeff Burnz’s picture

FileSize
599 bytes

Rerolled to include new user-picture class re http://drupal.org/node/382870#comment-1360548

Jeff Burnz’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch failed testing.

Jeff Burnz’s picture

FileSize
624 bytes

Wrong path, sorry, my noobness with core patches.

Jeff Burnz’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch failed testing.

Jeff Burnz’s picture

Status: Needs work » Needs review
FileSize
637 bytes

hmmm.

Status: Needs review » Needs work

The last submitted patch failed testing.

WorldFallz’s picture

FileSize
624 bytes
WorldFallz’s picture

Status: Needs work » Needs review

and let the bot check it out....

Status: Needs review » Needs work

The last submitted patch failed testing.

WorldFallz’s picture

Status: Needs work » Needs review
FileSize
607 bytes

another try with white space fix

Jeff Burnz’s picture

Hooray WorldFallz, thanks for cleaning that up, been a bit busy lately :)

WorldFallz’s picture

Status: Needs review » Reviewed & tested by the community

FINALLY, lol. OK, this is tiny, works, and passes testbot. Ready to go.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

andypost’s picture

Version: 7.x-dev » 6.x-dev
Status: Fixed » Patch (to be ported)
Issue tags: +Drupal 6 porting
FileSize
585 bytes

Strait backport

webchick’s picture

Status: Patch (to be ported) » Needs review

I think you mean this. "patch (to be ported)" means someone needs to write a backport which it looks like you already did. :)

That said, in D6 this seems like it might break themes that are already used to this behaviour. Not sure.

Jeff Burnz’s picture

Right now in most of my D6 themes I'm using my own user-picture.tpl.php as per the patch which I am forced to do. If any themes do rely on returning an empty div (unlikely I would think) this just reverses the situation, which I think is better and more appropriate. This is a bug/over site which should be fixed.

PixelClever’s picture

+1 for this commit.

There really isn't any way that this could break a theme to get this fixed. If they really need an empty div for some reason then they can always create one based on $picture being NULL. To not fix it requires acrobatic theming (or php) to work around it.

bmarcotte’s picture

FileSize
571 bytes

I'm running Drupal 6.15 (and 6.14) and I'm having the same problem. In my node-blog.tpl.php file I conditionally test $picture for content. if there is content I create a division blog-picture. The css for blog-picture contains float:left and some right/left margin so that the profile picture is on the left and the blog floats around it. If there is no picture, I still get the margin spaces. Obviously, this code would not run if $picture is empty, but even if there is no profile picture, $picture contains:

      <span id="thmr_12" class="thmr_call">
  <div class="picture">
  </div>
</span>

so the space is created. I would prefer $picture to be empty if there is no profile picture.

It seems that theme.inc's template_precess_node function themes $variable['picture'] irregardless of the variable's content. Thus if there is no profile picture, the function produces the span and div tags and stores them in $picture.

I modified theme.inc line 1941 to add the IF to conditionally theme 'picture':

   if ($variables['picture']) {$variables['picture'] = theme_get_setting('toggle_node_user_picture') ? theme('user_picture', $node) : '';};

Before this line is executed, $variables['picture'] contains the file location, after the call, it contains the themed picture. If ther is no picture, then $variables['picture'] is empty, and stays empty.

I'm new to this patching process. Attached is a patch I created with netbeans.

Best wishes to all,
Bob

andypost’s picture

#22 read more about http://drupal.org/coding-standards

This issue is about removing empty div if no picture assigned for user, so _preprocess stage make no sense at all

EDIT: dont forget about default picture!

bmarcotte’s picture

re:23 Hi Andypost
Sorry for over compacting the code. Not sure if that was your first point, but I can watch myself on that one.

I understand that the issue of this thread is to prevent generating an empty div. And, I am trying to do that in my blog node template file. The problem I see is that when the blog's owner does not have a profile picture, $picture in node-blog.tpl.php contains html wrapper tags, ONLY wrapper tags. So, if I'm going to test for the emptiness of $picture, it needs to be supplied to node-blog.tpl.php empty. With the best of my knowledge and ability, I routed it down to the preprocess function, where, it seems, an empty $picture gets themed. As I have been thinking about it, I'm kinda wondering why, in general, theme() would even wrap an empty input. then again, why would you call theme() with an empty variable...

Good point about the default picture, I did not test that condition. I could easily be wrong, but I would expect the default picture's file specification be placed in $picture before the theme call.

Sorry if I'm missing the boat here, but after having to modify code that seemed errant, I felt obliged to report it.
Bob

Status: Needs review » Needs work

The last submitted patch, theme_inc_patch.patch, failed testing.

nuwaninfo’s picture

The last submitted patch worked for me.

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.