Find all pdf links using a module Is there a way to find certain types of links and edit them from a custom module in Drupal 7? I want to add an attribute to all pdf links throughout my site. I tried the following:

function my_module_preprocess_link(&amp;$link){
  if( substr($link['path'], 4) === '.php' ) {
    var_dump($link);
  }
}


But I suppose since the pdf links are contained in the node content of my pages, they aren't included here.

I'd like to add a custom class to all pdf links or maybe an inline onclick javascript event. Is there a way to do that?
It depends how the links have been created.

If the links were added using a field, eg using the file module, then you could look to that module for it's theme functions, and create your own replacement theme function in your module or theme.

If (just reread your question) the links are included in the body (or other textarea field) of your site's nodes, then you would have to rely on an input filter to alter them before displaying the field. You could look to a module like ELF, for how this can be accomplished using an input filter, or 'External Links' for an example using javascript.