files_for_item — Get HTML for all files assigned to an item.

Item-related functions

Summary

files_for_item($options = array(), $wrapperAttributes = array('class' => 'item-file'), $item = null)

Get HTML for all files assigned to an item.

Parameters:
  • $options (array) –
  • $wrapperAttributes (array) –
  • $item (Item|null) – Check for this specific item record (current item if null).
Returns:

string HTML

Usage

Valid keys for the $options array are the same as those for the file_markup function’s $props argument. For details, see the Usage section for file_markup.

Attributes given in $wrapperAttributes are also simply passed as-is to the corresponding argument to file_markup.

Examples

To display image icons without a link to the image files:

<div class="element-text">
    <?php echo files_for_item(
        array(
            'linkToFile' => false
        )
    ); ?>
</div>

To add an attribute such as rel="lightbox" to the image links for use with lightbox:

<div class="element-text">
    <?php echo files_for_item(
        array(
            'linkAttributes' => array('rel' => 'lightbox')
        )
    ); ?>
</div>

To add css class and id selectors to the images:

<div class="element-text">
    <?php echo files_for_item(
        array(
           'imgAttributes' => array('id' => 'foobar')
        )
    ); ?>
</div>

To change the size of the images displayed for the item, for example to a fullsize image (this may be constrained by css):

<div class="element-text">
    <?php echo files_for_item(
        array(
           'imageSize' => 'fullsize'
        )
    ); ?>
</div>

To change the default icon displayed, particularly if an image is not generated for a particular file associated with an item. Image files must be located in ‘application/views/scripts/images’.

<div class="element-text">
    <?php echo files_for_item(
        array(
           'icons' => array('audio/mgep' => img('audio.gif'))
        )
    ); ?>
</div>

See Also