How do I alter the output of an existing views handler? How do I alter the output of an existing views handler?

I want to alter views_handler_field_user_picture() to get the link to the user profile, not the themed picture. 

See alter existing handlers (handler overrides). I expect a link like this http://cdn.sstatic.net/drupal/img/logo.png.

function mymodule_views_data_alter(&amp;$data) {
  $data['users']['picture']['field']['handler'] = 'my_custom_handler';
}


module .info 

files[] = user_picture_formatter.inc


and user_picture_formatter.inc is like this 

&lt;?php
class my_custom_handler extends views_handler_field_user_picture {
  function render($values) {
    if ($picture_fid = $this-&gt;get_value($values)) {
      $picture = file_load($picture_fid);
      $picture_filepath = $picture-&gt;uri;
    }
    else {
      $picture_filepath = variable_get('user_picture_default', '');
    }
    return $picture_filepath;
  }
}
?&gt;
The short answer is that you can't alter the output of a views handler. But what you can do is:


Create your own handler that is a subclass the handler you want to overwrite.
Add a render method - which will generate the output (this is where your alter code is)
Use hook_views_data_alter to make views use your handler instead where needed.


This will get the wanted effect, where you can alter the output of the original views handler, but in reality to make views use your custom handler.

In code it could look something like this.

class my_custom_handler extends views_handler_field_user_picture {
  function render($values) {
    ...
  }
}

function my_module_views_data_alter(&amp;$data) {
  $data[...]['handler'] = 'my_custom_handler';
}


This code is for Drupal 7, but the method can be used in both Drupal 6 and 7. For Drupal 7 you should create the class in it's own file and add the file to the module's .info file, to make Drupal autoload the file with the class when needed.