Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#22 | theme_inc_patch.patch | 571 bytes | bmarcotte |
#18 | user_picture_D6.patch | 585 bytes | andypost |
#14 | user-picture-v7-410044.patch | 607 bytes | WorldFallz |
#11 | user-picture-v6-410044.patch | 624 bytes | WorldFallz |
#9 | user-picture-v5-410044.patch | 637 bytes | Jeff Burnz |
Comments
Comment #2
Jeff Burnz CreditAttribution: Jeff Burnz commentedOk, lets try that again.
Comment #3
Jeff Burnz CreditAttribution: Jeff Burnz commentedRerolled to include new user-picture class re http://drupal.org/node/382870#comment-1360548
Comment #4
Jeff Burnz CreditAttribution: Jeff Burnz commentedComment #6
Jeff Burnz CreditAttribution: Jeff Burnz commentedWrong path, sorry, my noobness with core patches.
Comment #7
Jeff Burnz CreditAttribution: Jeff Burnz commentedComment #9
Jeff Burnz CreditAttribution: Jeff Burnz commentedhmmm.
Comment #11
WorldFallz CreditAttribution: WorldFallz commentedComment #12
WorldFallz CreditAttribution: WorldFallz commentedand let the bot check it out....
Comment #14
WorldFallz CreditAttribution: WorldFallz commentedanother try with white space fix
Comment #15
Jeff Burnz CreditAttribution: Jeff Burnz commentedHooray WorldFallz, thanks for cleaning that up, been a bit busy lately :)
Comment #16
WorldFallz CreditAttribution: WorldFallz commentedFINALLY, lol. OK, this is tiny, works, and passes testbot. Ready to go.
Comment #17
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.
Comment #18
andypostStrait backport
Comment #19
webchickI 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.
Comment #20
Jeff Burnz CreditAttribution: Jeff Burnz commentedRight 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.
Comment #21
PixelClever CreditAttribution: PixelClever commented+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.
Comment #22
bmarcotte CreditAttribution: bmarcotte commentedI'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:
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':
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
Comment #23
andypost#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!
Comment #24
bmarcotte CreditAttribution: bmarcotte commentedre: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
Comment #26
nuwaninfo CreditAttribution: nuwaninfo commentedThe last submitted patch worked for me.