Community & Support

Auto-resize user picture/avatar?

I'm looking for a prettier option that the default user picture settings. I looked at http://www.lullabot.com/articles/imagecache_example_user_profile_pictures, which has helpful steps for Drupal 4.7, but doesn't work with Drupal 5. Could someone point me in the right direction?

Comments

=-=

The link you point to , is a tutorial on how to do it in Drupal 5, not Drupal 4.7 ... could you please state where your problem lies with the tutorial and what isn't working ?

I'm testing using Drupal 5.1

I'm testing using Drupal 5.1 on XAMPP (PHP 5.2, mySql 5.0.27). Once I've followed the steps, and I try to add nodes/views or flush imagecache I get not-consistently-reproducable errors

- I sometimes get a blank page,with nothing in my logs
- I sometimes get "Cannot modify header information - headers already sent by (output started at .../themes/garland/template.php:22) in .../includes/common.inc on line 311." Location & Referrer = imagecache
- and sometimes it works fine

Thanks.

=-=

Just to clarify what logs are being looked at ? apaches ? or drupals ? blank page errors should be checked in apache logs.

have you tried the tutorial on a theme other than garland ? to try and narrow down where the problem may lie ? garland can be seen as a complex theme.

I appreciate your help with

I appreciate your help with this. I changed the theme to bluebreeze, which resulted in a blank page; and then I checked the apache logs, but couldn't find any corresponding errors.

I just looked at my .htaccess files (one in / and one in /files/). /files/.htaccess is exactly as it should be according to the tutorial. I will try another theme, and failing that, a fresh Drupal install.

=-=

the tutorial doesn't talk about changing anything in the root .htaccess , only in the files folder .htaccess ...

this may help too : http://drupal.org/node/1424

seems headers already sent errors are attributed to white space issues which is why per drupal coding standards, you shouldn't use a closing ?> php tag.

insure you don't have one in the module you created and the template code you added.

No dice so far: - confirmed

No dice so far:

- confirmed the /files/.htaccess file is as it should be
- started with a clean install (Drupal 5.1, imagecache v 1.1.2.2, imagecache_profile module downloaded zip files from tutorial)
- add a user, results in blank page but user is added
- nothing in apache logs, but "warning: Cannot modify header information - headers already sent by (output started at /opt/lampp/htdocs/sandbox/themes/box_grey/template.php:22) in /opt/lampp/htdocs/sandbox/includes/common.inc on line 311" in the Drupal log

=-=

I added to my post above about same time you posted this, with reagrds to closing php tags and headers already sent errors. have you inspected ?

I cut and pasted exactly

I cut and pasted exactly what is in the tutorial, into the existing template.php, without removing any closing tags. Could you let me know how I should edit my current file:

<?php
/**
*
* Insert into your theme's template.php file:
*
* Theme override for user.module
* Utilized imagecache module to scale down large uploaded profile pictures
* @param $size
*   Image size to scale to. Options: thumb (default) and large
*/
function phptemplate_user_picture($account, $size = 'thumb') {
  if (
variable_get('user_pictures', 0)) {
   
// Display the user's photo if available
   
if ($account->picture && file_exists($account->picture)) {
     
$picture = theme('imagecache', $size, $account->picture);
    }
    return
'<div class="picture">'.$picture.'</div>';
  }
}
?>


<?php
function phptemplate_image_gallery($galleries, $images) {
  return
_phptemplate_callback('image_gallery', array('galleries' => $galleries, 'images' => $images));
}
?>

=-=

If you are already using a theme that has a template.php these already have an opening <?php
Thus you shouldn't be adding "extra" <?php tags. Drop the opening and closing php tags in the code above and test.

like so:

/**
*
* Insert into your theme's template.php file:
*
* Theme override for user.module
* Utilized imagecache module to scale down large uploaded profile pictures
* @param $size
*   Image size to scale to. Options: thumb (default) and large
*/
function phptemplate_user_picture($account, $size = 'thumb') {
  if (variable_get('user_pictures', 0)) {
    // Display the user's photo if available
    if ($account->picture && file_exists($account->picture)) {
      $picture = theme('imagecache', $size, $account->picture);
    }
    return '<div class="picture">'.$picture.'</div>';
  }
}

function phptemplate_image_gallery($galleries, $images) {
  return _phptemplate_callback('image_gallery', array('galleries' => $galleries, 'images' => $images));
}

php files only need one opening <?php tag and with Drupal never needs a closing ?> tag. Leaving the closing tag off eliminates "white space" errors that occur when spaces or lines are added after the closinig tag.

Thus, if the only thing in the template.php is this code then it should look like this

<?php
/**
*
* Insert into your theme's template.php file:
*
* Theme override for user.module
* Utilized imagecache module to scale down large uploaded profile pictures
* @param $size
*   Image size to scale to. Options: thumb (default) and large
*/
function phptemplate_user_picture($account, $size = 'thumb') {
  if (variable_get('user_pictures', 0)) {
    // Display the user's photo if available
    if ($account->picture && file_exists($account->picture)) {
      $picture = theme('imagecache', $size, $account->picture);
    }
    return '<div class="picture">'.$picture.'</div>';
  }
}

function phptemplate_image_gallery($galleries, $images) {
  return _phptemplate_callback('image_gallery', array('galleries' => $galleries, 'images' => $images));
}

Yay! It was the

Yay! It was the opening/closing trickery. My complete box_grey/template.php file now looks like:

<?php
/**
*
* Insert into your theme's template.php file:
*
* Theme override for user.module
* Utilized imagecache module to scale down large uploaded profile pictures
* @param $size
*   Image size to scale to. Options: thumb (default) and large
*/
function phptemplate_user_picture($account, $size = 'thumb') {
  if (variable_get('user_pictures', 0)) {
    // Display the user's photo if available
    if ($account->picture && file_exists($account->picture)) {
      $picture = theme('imagecache', $size, $account->picture);
    }
    return '<div class="picture">'.$picture.'</div>';
  }
}

function phptemplate_image_gallery($galleries, $images) {
  return _phptemplate_callback('image_gallery', array('galleries' => $galleries, 'images' => $images));
}

=-=

congrats : )

Thank _you_ !

Thank _you_ !

=-=

no problem glad to help and glad it got sorted for you!

Subscribing for followup

tmg-studio (Jamie)

--
Jamie Meredith : Music City Networks : Vice President of Business Development
209 10th Ave South : Suite 400 : Nashville, TN. 37203
ph: 615.250.2130 : cell 615.440.1915

My Calendar - https://tungle.me/JamieMeredith
LinkedIn - http://www.linkedin

related tutorial failing

I was just tooling around trying to step through the previous Lullabot demo. I tried to do the same with their related http://www.lullabot.com/articles/image_and_image_exact_sizes_vs_imagefie... tutorial.

- Used CCK image field
- And imagecache

I've run through the tutorials a few times, and files/imagecache/thumb/... gets created fine, but filges/imagecache/product_images/... doesn't. Any help?

Drupal 5.1, CCK 5.x-1.5, imagecache 5.x-1.3

Try out the ImageCache

Try out the ImageCache Profiles module.

ImageCache_Profiles module allows you to set user profile pictures that are consistent throughout your site and allows avatars on the user profile pages to be a different size.

Please submit any bug reports or feature requests after giving it a spin.

ImageCache profiles works

ImageCache profiles works PERFECT!

Check out the instructions/readme on how to make it work

Jason.Brain @ WeBeWho!com
IT, Web, Marketing and Promotional Solutions
Kawartha Lakes, Ontario

nobody click here