Home › Forums › General Issues › Mime type for file uploads
I am using ACF to add a custom file attachment (returning the file object) to my posts. The data returned using get_field() is rather limited.
(
[id] => 218
[alt] =>
[title] => PRESENTATION
[caption] =>
[description] =>
[url] => http://localhost/path/to/file.doc
)
If I do a wp_query against the post I can retrieve all of the details by inspecting the attachments array:
{
"id": 218,
"url": "http:localhost/path/to/file.ppt",
"slug": "presentation",
"title": "PRESENTATION",
"description": "",
"caption": "",
"parent": 217,
"mime_type": "application/vnd.ms-powerpoint"
}
I would rather not make a new WP_Query since I am in the_loop at the time I need access to this data. Is there any ACF way of getting the mimetype associated with a file upload?

Hi @oravecz
Thanks for the question.
Currently, ACF does not return the mime type, however, this seems like a good idea.
Can you list any other attributes you would like the file type to return?
Thanks
E
Well, mime_type is the one I was interested in. In WordPress’s normal media/attachment workings there is additional metadata stored if the item is a video file or image file.
http://codex.wordpress.org/Function_Reference/wp_read_image_metadata
http://codex.wordpress.org/Function_Reference/wp_read_video_metadata


Hi @oravecz
Just wanted to let you know that mime_type has now been added to the image and file return data!
I’ll take a look at the read_metadata functions. They looks pretty interesting!
Thanks
E
The topic ‘Mime type for file uploads’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.