If a user does not have a profile picture, the site's default user picture is not used correctly instead. Patch attached.

CommentFileSizeAuthor
default-picture.txt1.81 KBbjaspan

Comments

omnyx’s picture

same here - i can't get my default picture to show when I view the profile page. However, it is being displayed when I'm editing the profile page (under the 'change your profile picture' field)

Will try the patch

solutiondrop’s picture

Has anyone gotten this patch to work? It doesn't work as far as I can tell. I patched it correctly but there is no change.
Thanks.

reed.richards’s picture

I tried the patch and it actually resolved another problem I was having with the user_image_default i.e. the smaller image uploaded by the user.

  print theme('imagecache', 'user_image_default', $user->picture);

However I get an error with the local module after applying the patch saying

Notice: Trying to get property of non-object in D:\www\allahundar\modules\locale\locale.module on line 175 It also messes up my admin theme so the default theme will show in admin mode...

Further on now trying the patch by deleting the user's picture and setting the default picture I get nothing. My intuition was that loading a user object, imagecache_profile would add the paths etc. as extra attributes to the user object.

This module is a bit poorly documented.

reed.richards’s picture

So I've spotted the problem on line 48 in the module there's a line like this

  theme('imagecache', $size, variable_get('user_picture_default', '')) 
 

Now as I understood it imagecache is supposed to be able to do stuff on the fly but I was wrong, this is how the theme_imagecache function looks like:

  function theme_imagecache($namespace, $path, $alt = '', $title = '', $attributes = NULL) {
  $attributes = drupal_attributes($attributes);
  $imagecache_path = file_create_url(file_directory_path() .'/imagecache/'. $namespace .'/'. $path);
  return '<img src="'. $imagecache_path .'" alt="'. check_plain($alt) .'" title="'. check_plain($title) .'" '. $attributes .' />';
}

Obviously calling this at err while the $imagecache_path get messed up thus the logical error message ImagCache - Could not create destination...

So conclusion: Get rid of the theme_imagecache call and replace it with a better theme calling function or just a line which creates the image and returns it.

Further on there seems to be problem when doing an override of the phptemplate_user_profile which doesn't get the phptemplate_user_picture started.

Tomorrow I try to write a patch or at least a copy & paste and try solve the error of the not calling.

Selah.

reed.richards’s picture

So fixing the stuff temporarily, in the module between line 46-57 there is

    elseif (variable_get('user_picture_default', '')) {
      if (isset($size)) {
        $picture = l(theme('imagecache', $size, variable_get('user_picture_default', '')), 'user/'. $account->uid, array('title' => t('View user profile.')), NULL, NULL, FALSE, TRUE);
      } else {
        $picture = file_create_url(variable_get('user_picture_default', ''));
        $alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous'))));
        $picture = theme('image', $picture, $alt, $alt, '', FALSE);
        if (!empty($account->uid) && user_access('access user profiles')) {
          $picture = l($picture, "user/$account->uid", array('title' => t('View user profile.')), NULL, NULL, FALSE, TRUE);
        }        
      }
    }

Replace it with


    elseif (variable_get('user_picture_default', '')) {
      	$picsrc = file_create_url(variable_get('user_picture_default', ''));
     	$alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous'))));
	    $picture = theme('image', $picsrc, $alt, $alt, '', FALSE);	    
        if (!empty($account->uid) && user_access('access user profiles')) {
        	$picture = l($picture, "user/$account->uid", array('title' => t('View user profile.')), NULL, NULL, FALSE, TRUE);
        }        
      }

And remember the path to your default image is relative your files directory.

The only problem with this is that the default picture is only one size the size you choose when uploading stuff this can mess up your layout. Would be nice if the module actually did the presets on the default image and then saved it in the right catalogue. With the new imagefield default image thingy I am guessing you can do that just by applying the imagecache preset to the field. So I am seriously thinking about migrating the userpicture to a nodeprofile which will make things easier but remove the image showing in drupal core...

Best would be if this module just would add the imagepath to the user image in the imagefield is behaving with imagecache put on it.

socialnicheguru’s picture

subscribing.

v1nce’s picture

Status: Needs review » Fixed

Committed to dev version.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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