Does anyone know how I can get rid of a href when I want to use print $picture in my node template.

Comments

ionut.alexuc’s picture

I think you want to remove the link and only to display the image without link to the user profile.

do you want to change that globally or only in node template?

1. only locally.
you could use something like:

$account = user_load($nid); // where $uid is the id of the author
print '<img src="'.$author->picture_path.'" alt="Some text here" />

You have to check the $author->picture_path, I don't think that is ok.

You could try:

print_r($account);

and you will see all properties of the $account and then you can access the path to the user's image.

ionut.alexuc’s picture

If you want to change it globally.

Here is the function that you need:
http://api.drupal.org/api/function/template_preprocess_user_picture/6

You have to get that function and copy/paste it into your theme/template.php.
Rename it to your theme name.
Edit it like:

function THEMENAME_preprocess_user_picture(&$variables) {
  $variables['picture'] = '';
  if (variable_get('user_pictures', 0)) {
    $account = $variables['account'];
    if (!empty($account->picture) && file_exists($account->picture)) {
      $picture = file_create_url($account->picture);
    }
    else if (variable_get('user_picture_default', '')) {
      $picture = variable_get('user_picture_default', '');
    }

    if (isset($picture)) {
      $alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous'))));
      $variables['picture'] = theme('image', $picture, $alt, $alt, '', FALSE);      
    }
  }
}

Delete the section with drupal l-function.

Metalviking’s picture

Thank you it works.

But now I have another problem.

The picture is to large and I am using ImageCache to make them the same size.

ionut.alexuc’s picture

Ok, for that use .css.

Use firbug if you don't use it, and investigate the image.
See if it has a class or find a parent that has a class.

Then, go to your theme/theme.css file and add:

.image-class {
width: 100px;
}

or if you have a parent that has a class or ID.
.parent-class img {
width: 100px;
}

OR

#parent-id img {
width: 100px;
}

you could set also the height of the image, then the browser will resize it and you will lose quality.
If you set only widht or height, it will be resized accrodingly, and it will keep the aspect ratio

Metalviking’s picture

Great

Everything is working fine now.