How to properly alter the output for fields of type file? I have a file upload field which's format is set to generic file. It prints the following markup:

&lt;div class="content"&gt;
  &lt;span class="file"&gt;
    &lt;img class="file-icon" alt="" title="application/msword" src="project/modules/file/icons/x-office-document.png"&gt;
    &lt;a href="urltofile.doc" type="application/msword; length=22016" title="file.doc"&gt;Lorem ipsum&lt;/a&gt;
  &lt;/span&gt;
  &lt;span class="file"&gt;
    ...
  &lt;/span&gt;
&lt;/div&gt;


But I'd rather not show the img at all, alter url text, something similar like this:

&lt;div class="content"&gt;

  &lt;span class="file maybe-some-custom-classes"&gt;
    &lt;a href="urltofile.doc"&gt;$filename&lt;/a&gt;
    &lt;span&gt;$description text of this field&lt;/span&gt;
  &lt;/span&gt;

&lt;/div&gt;


What hooks would I have to use for this? And why is this so hard to find on the docs?!
I'm guessing a bit here as I can't see what you have installed/configured...

The file formatter function is file_field_formatter_view(), and the only formatter which has an image attached to it runs through theme_file_link(). I would assume that's where the markup you're referring to comes from.

You can override that in your theme:

function MYTHEME_file_link($vars) {
  ...
}


Or, if you can get away without having to reproduce the function, just preprocess is:

function MYTHEME_preprocess_file_link(&amp;$vars){ 
  ...
}