How can I convert a filetype into an icon?

I have created a number of repeatable metafields to contain data for product page downloads - data sheets etc.

I can display each item in the following format:

pdf 136KB Proximity Click 14 Schematic

However, I want to replace the filetype (pdf in this example) with an icon.

Can anyone suggest a function for converting a three-character filetype into an icon URL?

Many thanks.