The item_file()
helper will display the value of a specific metadata field for a file.
Usage
<?php echo item_file( $elementSetName, $elementName, $options = array(), $file = null ); ?>
Arguments
- elementSetName - The name of the element set. If none is given, see section below on Displaying Regular File Metadata.
- elementName - The name of the element.
- options - (array) An array of options.
- file - The file object. Default value is null. If null, the current file is used.
Examples
Displaying Regular File Metadata
There are a few fields for files that are not associated with a specific Element Set:
- id
- archive filename
- original filename
- Size
- MIME Type
- Date Added
- Date Modified
- Authentication
- MIME Type OS
- File Type OS
- uri
- fullsize uri
- thumbnail uri
- square thumbnail uri
- permalink
To display the value for any of these fields, simply use that field name as the first argument for item_file
:
<?php echo item_file('id'); ?>
Keep in mind that field names are case sensitive and must be used as they are written above. For example, if you want to extract the MIME Type
of a file you use:
<?php echo item_file('MIME Type'); ?>
Displaying Dublin Core elements
To display elements in the Dublin Core element set, you need to specify that element set name first. The following example will display the Title field in the Dublin Core element set:
<?php echo item_file('Dublin Core', 'Title'); ?>