Support

Account

Home Forums General Issues Mime type for file uploads

Solved

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

    Thanks for the links

  • 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

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Mime type for file uploads’ is closed to new replies.