How to retrieve mime type for the current get attachment

I’m uploading some pdf files and .doc/docx files in a project.
So, I’m inserting a link attachment file inside the loop and is working fine.

But I need to get a specific attribute: the mimetype.

Read More

So, I need to print the attachment url and mimetype, like this

Download file on http://domain.com/wp-content/…file.pdf
File Type: pdf or application/pdf

Could someone help me with this?

By the way, I´m using a custom theme and not the default wordpress theme.

Thanks a lot.

Flávio

Related posts

Leave a Reply

2 comments

  1. If you are indeed dealing with an attachment post type inside the loop, you should be able to access the post_mime_type:

    global $post;
    $mime_type = $post->post_mime_type;
    

    global $post may already be set, but if not, it is necessary in order to access the post data.