File Type renderer macro

Is it possible to create a macro that will render a particular file type if an attachment of that file type is inserted into a Confluence page. If so can someone point me in the right direction as to what kind of macro I should create?