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

Controls the display of icons to represent the files associated with an item.

Valid keys for the $options array are:

  • linkToFile: Whether icon includes a link to the file. Takes a boolean value and default is “true”.
  • linkAttributes: Takes an array of additional attributes for the image link. Default attributes are array('class'=>'download-file', 'href'=>$file->getWebPath($derivative)).
  • imgAttributes: Takes an array of selector names and values for the image element. Default is none.
  • imageSize: Takes a value of the image size to be displayed. Valid values are fullsize, thumbnail, and square_thumbnail.
  • icons: Takes an array of the MIME type and the name of an image file in application/views/scripts/images to change default image icon.

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