Forums: Extracting file MIME type

  1. This seems simple enough but the answer seems to be eluding me. I want to extract the mime type of a "Moving Image" file attached to an item into a variable for use later in my plugin. My function is passing the $item object and I am testing to verify the $item has a file. But if I do the following:

    $fileMime = item_file('mime type', get_current_file());
    echo '<p>' . $fileMime . '</p>';

    the plugin stops at the point the call is made with no errors. If I change the 'mime type' part to any other valid item like 'size' it still stops at that call. What I am hoping it would do is echo something like

    video/x-m4v

    Am I calling the wrong function? Am I not passing the right $item object? Other components like $title = item('Dublin Core', 'Title', $item); work fine so am I missing a link somewhere? ANy help would be appreciated.

  2. Even tho this is on the Developers forums I will also post the solution here just in case. The problem was in the case of the item_file call. For MIME types is must be exactly the following:

    item_file('MIME Type')

    Anything else will result in an error. I originally had this as item_file('mime type') as it was listed int he documentation which is incorrect.

  3. Thanks for posting this here, Greg, and for correcting the documentation!

Topic Closed

This topic has been closed to new replies.