I've just u/g to 4.4 and it's working well. I am still defining and completing my site locally.
I have the default avatar showing for comments and nodes, but cannot get avatars to work with each account. Every time I browse and choose one, it is created in the correct /files/avatars subfolders, but as soon as I save the settings , the box goes blank and the default avatar is not replaced. If i remove the default avatar, I just get a text link to 'edit account'

I've tried different ways of entering the avatar address:
file:///C:/FoxServ/www/drupal/files/avatars/general_avatar.jpg
file:///general_avatar.jpg
general_avatar.jpg
etc.

anyone know what i'm doing wrong?

Comments

duztin’s picture

I'm having the same problem, let me know if you get it fixed please

duztin’s picture

I used to host on 1and1 but I switched to jc-host and that fixed all the avatar problems.

hone’s picture

I'm having the same problems, but when I checked the database in the user table under the column data you can find the text "profile_avatar" and I'm assuming after that is the path of the picture. This is what I get: "profile_avatar";s:14:"/tmp/phpnhh95t";

I think that may be a problem, it's not storing it right.

It's funny because it uploads it right because I can access it via http, http://www.wornpath.net/files/avatars/avatar-1.png
--
Hone
wornpath.net Admin
hone@wornpath.net

timsline’s picture

Same issue, changing the path directly in the users profile via mysql doesn't help either, it just makes their entire profile show up blank. My issue is below.

I am also having a similar problem with my avatars. Users can upload them just fine, they go to the correct directory of my site, but when they are called up on the profile pages for example, they are trying to grab the avatar from the wrong place. For example, the correct location is
http://thecphookup.com/files/avatars/avatar-43.jpg
instead it points to http://thecphookup.com//home/site/public_html/thecphookup/files//avatars...

The problem seems to be where the profile.module is getting the image path I guess. Under the admin/system/modules/profile page it says "Subdirectory in the directory '/home/site/public_html/thecphookup/files//' where avatars will be stored." for the avatar path, so I know that's the wrong, but I don't know where to fix it from. Again, it is uploading the avatars correctly and to the correct location, but it is displaying the path to them incorrectly in the users profile.

Any help would be greatly appreciated.

grohk’s picture

The path can be relative, instead of absolute. Here is what I have in my User Module settings:

Picture support:
Enabled

Picture image path:
picture

Default picture:
files/pictures/c0-avatar.png

It is displaying properly in the user profile, but I haven't gotten it to display in comments or nodes. I am using a beta version of phptemplate though and think its a bug.

Good Luck.

cooties’s picture

Similar problem - the path to the images seemed to be a combination of a URL and the server. Didn't matter what I put in the 'files' entry, it would always come up with http://drupal.akacooties.com/drupal.akacooties.com/files/home/akacooti/w...

SO, I edited my profile in PHPAdmin, but so path to the image is now 'http://drupal.akacooties.com/drupal.akacooties.com/files/avatar-1.jpg' so it's a start.

I have no idea where the extra domain is coming from, though the other path was what I'd used originally before using just 'files' (and Drupal accepted it as an existing directory).

I'm no help to you, but I'm relieved someone else is having the same problem.

marky’s picture

I'm running Drupal 4.4.1 on w2k with Apache2 and php4.3.6 as a module, and 'clean url' support through mod_rewrite. This may not be akin to everyone else's setup, but I hope you get the general idea... ;)

Drupal is installed in the webroot, and the directory structure contains a dir 'files' with a subdir 'avatars'. System settings:

admin/system
File system path: files
Download method: Private - files are be transferred by Drupal.
admin/system/modules/profile
Avatar image path: avatars

I'm using a customised version of the chameleon.theme. The standard version has no support for avatars so I just ripped the function from xtemplate.theme, who has the required support. I only need avatars in comments so that's what I'll illustrate. Here's my entire chameleon_comment() function; adapt to suit:

function chameleon_comment($comment, $link = "") {

  if (module_exist("profile")) {
    $avatar = $comment->profile_avatar;
    $avatar = file_create_url($avatar);
  if ($avatar) {
    $avatar = "<img src=\"$avatar\" alt=\"" . t("%user's avatar", array("%user" => $comment->name ? $comment->name : t(variable_get("anonymous", "Anonymous")))) . "\" />";
    }
  if ($comment->uid) {
    $avatar = l($avatar, "user/view/$comment->uid", array("title" => t("View user profile.")));
    }
  }

  $submitted = array(t('By %author at %date', array('%author' => format_name($comment), '%date' => format_date($comment->timestamp. 'small'))));
  $links = array($link);

  $output  = "<div class=\"comment\">\n";
  $output .= " <h3 class=\"title\">". $comment->subject ."</h3>\n";
  $output .= " <div class=\"avatar\">". $avatar ."</div>\n";
  $output .= " <div class=\"content\">". $comment->comment ."</div>\n";
  $output .= " <div class=\"links\">". theme('links', array_merge($submitted, $links)) ."</div>\n";
  $output .= "</div>\n";

  return $output;
}
This gives me the parsed path:
<img src="system/files?file=avatars%5Cavatar-1.gif" alt="marky's avatar">

I can then style it with:

.avatar{
   float: right;
   border: 0;
   padding: 0.5em;
}

which gives me an image in the top right corner of my comments that links to my profile. If you need them in posts just add similar stuff to function chameleon_node(). HTH :)

grohk’s picture

I am using PHPTemplate and was having issues with Avatars. But now I got it thanks to your suggestion. Thanks!

char-1’s picture

Hi,

Just tried copying this into my template. It's working great for users with avatars (straight pic) and anonymous users (blank), but providing a broken image box for registered users without anything set-up. How can I feed it a default avatar to show?

ceti’s picture

Thanks for the code! For at least 4.6, folks will need to change:

  if (module_exist("profile")) {
    $avatar = $comment->profile_avatar;

to

  if (module_exist("user")) {
    $picture = $comment->picture;

as the avatar is now a picture in the user module.

You also have to add NULL, NULL, FALSE, TRUE after the array parameters as in here:

    $avatar = l($avatar, "user/view/$comment->uid", array("title" => t("View user profile.")));
    $avatar = l($avatar, "user/view/$comment->uid", array("title" => t("View user profile.")), NULL, NULL, FALSE, TRUE);

for the img src to code properly in the file.

manon@penandpencil.net’s picture

I got the code to work for uploaded avatars, but I don't know how to get the default avatar to show up as well. If anybody could help me with this, I would greatly appreciate it!

bradlis7’s picture

For users without avatars, you need to change the following:

if (module_exist("user")) {

to:

if (module_exist("user") && $comment->picture) {

Or, instead, if you'd like to use a default picture (in response to manon@penandpen), change:

$avatar = $comment->picture;

to:

if($comment->picture) {
  $avatar = $comment->picture;
} else {
  $avatar = [[default picture here...]];
}
gdboling’s picture

Same exact problem here except I can't even get the default Avatar to show up.

Sandman77’s picture

" I have the default avatar showing for comments and nodes "

How do I turn on that?

duztin’s picture

The settings are at admin/system/themes/phptemplate at the bottom of the page. I don't know if all the themes support it but phptemplate does.

robert castelo’s picture

As does xTemplate!

------------------------------------------
Drupal Specialists: Consulting, Development & Training

Robert Castelo, CTO
Code Positive
London, United Kingdom
----

Sandman77’s picture

marvin_2k doesnt :(

timsline’s picture

Alas my problem

sciman’s picture

In 4.6.3, does anybody have a clue how to delete avatars from one node type but not others? As administrator of a site, for instance, I'd like to have avatars associated with forum posts but not necessarily every book page in the site.. though that's what's happening if I put an avatar in my profile and use the great civicspace theme. I'd like to control what node types avatars appear with, but don't need them in books, pages, polls, etc. Any tips would be much appreciated since I don't see phptemplate in 4.6.3 admin menus.

bradlis7’s picture

This works for a plain theme. I'm going off of marky's and ceti's comments. This is kind of a hack, because there's no option to configure this without removing the code. If you'd like to view the avatar on pages with teasers, remove "!$main" on the first line. Also, if you'd like for it to show up on different node types, change "$node->type == 'forum'".

  if(theme_get_setting("toggle_node_user_picture") && $node->type == 'forum' && !$main) {
    if (module_exist("user") && $node->picture) {
      $avatar = $node->picture;
      $avatar = file_create_url($avatar);
      if ($avatar) {
        $avatar = "<img src=\"$avatar\" alt=\"" . t("%user's avatar", array("%user" => $node->name ? $node->name : t(variable_get("anonymous", "Anonymous")))) . "\" />";
      }
      if ($node->uid) {
        $avatar = l($avatar, "user/view/$node->uid", array("title" => t("View user profile.")), NULL, NULL, FALSE, TRUE);
      }
    }
    $output .= " <div class=\"avatar\">". $avatar ."</div>\n";
  }
akamarvin’s picture

it works (profile infos are loaded) under admin/user/edit but not in user/edit. That shall be a good clue to resolution, i'm investigating...

akamarvin’s picture

the name of the avatar file when uploaded stays the same for a person, based on his id, so you got avatar-15.jpg or avatar-15.png.

Thus when you replace your avatar for another one with the SAME extension/type the name of the file really does not change and is therefore not reloaded by the cache of the browser !

Leading to no change in the user edit form and profile info page.
You got to force the reload of your page ,and thus the image, to get your browser to display the right image.

One solution could be ( in the right place of the code) to save alternatively the avatar as avatar-xx_a.jpg then avatar-xx_b.jpg with a simple check of the name of the already saved file. So for every modification of the avatar, you got a change in its uploaded filename.

Or maybe something else more php-ish to force the reload ?

duztin’s picture

I've noticed this problem and have just hit reload to force the avatar to save, If you do find a fix for this problem keep me in mind please.

jni’s picture

Login with the admin account and change your 'File system path:' to files. Dont write the physical path of the server, cause then it won't work (as you might have noticed). This dir has to be created on the server in the htdocs dir, and chown to the right user (httpd/apache/www/whatever user). In your module profile configuration you change 'Avatar image path:' to avatars (or something). Just remember to create the directory below the above 'files' directory. Voilá.

TheoGB’s picture

For some reason it just refuses to upload the avatars. According to the profile section the avatars directory is writable and I've definitely checkec all the boxes, but when I attempt upload in the profile it doesn't work.

So I simply altered the database to have the correct information and uploaded the avatars manually. Pain in the ass but it works now! :-D