[Answered] Profile picture
Hi!
The Lullabot article was excellent! You have to try it! It is perfect!
The profile picture is shown correct everywhere except for in the buddy list in the user profile and when someone leaves a message in the guestbook. In these 2 cases the profile picture is shown instead of the thumbnail.
<?php
//in the userlisting:
print theme('user_picture', $profileuser, 'thumb');
//in the profile:
print theme('user_picture', $profileuser, 'large');
//Instead of your orignal code in node-uprofile.tpl.php:
print theme("user_picture",$profileuser);
?>Where do you set how large the user pictures should be set in the guestbook and the buddy list in the user profile?
By the way which editor do you use for this text field (it is not TinyMCE)?
Thanks!
theme_user_picture is the standard Drupal api function here:
http://api.drupal.org/?q=api/function/theme_user_picture/5
I don't know why these two instances aren't affected buy the Lullabot tutorial, though. Sorry I'm not more help than that... I haven't actually tried the article yet.
The editor is bueditor.
Michelle
Tho it's not recommended, but seeing that the difference between thumbnail and avatar sizes needed for buddylist are not too big, I used the CSS resizing to, say 40x40. Hope that may help a bit.
Gaus...
Maybe you could post your solution here... CSS, modified modules etc.? i am looking for the right solution for my pages too!
Do the important tuts from lullabot mentioned above for imagecache settings.
In your views_buddylist_of_uid.tpl.php, enclose the picture display code with, say:
your picture! code only.., If you want also to include the username you can give another div to keep them intact.
In your CSS, place:
.avatar{float:left;display:inline;width:40px}
This will display your buddies in MyBlogLog like.
Cheers! Or else, try create your Profile on my site, and see the CSS codes on the given default buddy there thru Firebug or web developer extensions, available for IE and FF, once you are at your Profile page. You can delete or ask me to later your account, if you so wish.
What code do you mean I should put into views_buddylist_of_uid.tpl.php?
Like this?
print theme('user_picture', $profileuser, 'thumb');
Thanks!
Seth
Suppose you pick div class avatar, as mentioned above:
<div class="avatar">
<?php print $uid?>
<br />
<?php print l($name, "user/$usernode_users_uid")?>
</div>I did that directly as all other picture displays are set to thumbnail, save for the profile display which is set to larger ones.
Good luck!
This is the code compiled from various commenters at lullabot that suits my need in the meantime:
function theme_user_picture($account, $size = 'thumbnail') {
if (variable_get('user_pictures', 0)) {
if (preg_match('/q\=user\/\w+/', $_SERVER['REDIRECT_QUERY_STRING'])) {
$size = 'medium';
}
if ($account->picture && file_exists($account->picture)) {
$picture = l(theme('imagecache', $size, $account->picture . '?' . time()), 'user/' . $account->uid, NULL, NULL, NULL, FALSE, TRUE);
}
else if (variable_get('user_picture_default', '')) {
$picture = l(theme('imagecache', $size, variable_get('user_picture_default', '')), 'user/' . $account->uid, NULL, NULL, NULL, FALSE, TRUE);
}
return '<div class="picture">'.$picture.'</div>';
}
}I don't understand what you want to achieve with this code? Print picture and username? My problem is that I get the large profile picture and not the thumbnail. (if a user has put up a small picture it will be surrounded with black).
What is your CSS code for ?
This is the code I have taken from the lullabot article and put in template.php:
<?php
Function phptemplate_user_picture($account, $size = 'thumb') {
if (variable_get('user_pictures', 0)) {
// Display the user's photo if available
if (preg_match('/q\=user\/\w+/', $_SERVER['REDIRECT_QUERY_STRING'])) {
$size = 'large';
}
if ($account->picture && file_exists($account->picture)) {
$picture = l(theme('imagecache', $size, $account->picture), 'user/' . $account->uid, NULL, NULL, NULL, FALSE, TRUE);
}
else if (variable_get('user_picture_default', '')) {
$picture = l(theme('imagecache', $size, variable_get('user_picture_default', '')), 'user/' . $account->uid, NULL, NULL, NULL, FALSE, TRUE);
}
return '<div class="picture">'.$picture.'</div>';
}
}
?>Thanks!
Seth
My mind was on answering another question here (quote from Anonymous: The profile picture is shown correct everywhere except for in the buddy list in the user profile and when someone leaves a message in the guestbook.) by the Anonymous above. Visitor and Anonymous are just everyone here. So your name may help me address you well.
Concerning your questions, then lullabot tut on imagecache_profile should answer yours. Or if you prefer to have your site all display the thumbnail size, then you should omit this part:
// Display the user's photo if available
if (preg_match('/q\=user\/\w+/', $_SERVER['REDIRECT_QUERY_STRING'])) {
$size = 'large';
}Isn't that what you need? If you want a check for the minimum size allowed, then the module included in the tut did that for you. With the minimum size preset, it's hopefully to avoid unnecessary dark edges.
Goodluck!
Hi!
I get dark edges on all pictures that are too small. Is it possible to make them white?
I didn't get this (sorry...):
If you want a check for the minimum size allowed, then the module included in the tut did that for you. With the minimum size preset, it's hopefully to avoid unnecessary dark edges.
How do I avoid the black edges (or make them white)?
Thanks!
Seth
Sorry, Michelle. This should go to lullabot.
I have no idea yet for how to make it white, but I know how to avoid dark edges.
This part in the module do the check fo the minimum:
<?php
function imagecache_profiles_user_edit_validate($form_id, $form_values) {
// Add a minimum size requirement to the image upload form
if ($info = file_check_upload('picture_upload')) {
$image_info = image_get_info($form_values['picture']);
if ($image_info['width'] < 160 || $image_info['height'] < 160) {
form_set_error('picture_upload',t('Your profile image must be at least 160 pixels wide and tall (your image was @width x @height pixels).',array('@width' => $image_info['width'], '@height' => $image_info['height'])));
}
}
}
?>So, if you allow the minimum less than 160, you'll have the dark edges when you set the display larger than the picture uploaded by the user. The trade-off is set your imagecache preset for the thumbnail to be lower than 160. Or else try to increase the value if you want to enforce larger display. And don't forget to clear browser cache if you have problems with the update. Cheers!
So, if you allow the minimum less than 160, you'll have the dark edges when you set the display larger than the picture uploaded by the user.
So that is exactly what I would like to have: To let the users upload images around 160px, but always display it at 220px in the user profile page, without dark edges.
If a user uploads an image at 160px, I would like it to be displayed in the user profile without dark edges. Possible?
I don't want to force users to upload big images (then they might skip uploading), but I would like to have pictures without black borders.
Thanks!
Seth
Try not to do the Crop action in the imagecache preset. I you've done so already, then just delete the action. You can always go back if you change your mind later. Just do the Scale or Resize. The consequence is you won't have uniform sizes, but POSSIBLY eliminate that dark thing.
Or else, just edit! give the module minimum preset as seen in the above code a rise to 220px as you wanted them to be in the display. And do the CSS thing to that size just to reduce the mentioned consequence a bit, such as:
.picture {width:220px}Good luck!
I'm sorry, I'm trying to figure out how to get the image used with guestbook on the profile to be the normal size of imagecache profiles. This seems to be the most informative post on the subject online, sorry michelle, but I appreciate it.
Gaus, can you elaborate on what needs to be done to not use the full size profile picture in the Guestbook entry? I want to use the same size avatar (100x100) that imagecache uses throughout the site. Do I paste that code into something in particular? Thanks, hopefully this is still being monitored.


Site contents are licensed under a
I don't do anything special with them right now. Thinking of implementing
http://www.lullabot.com/articles/imagecache_example_user_profile_pictures
some day, though.
Michelle