Files Plugin
The files plugin allows users to list files inside a folder, display paths to images, create download links, and display resized images
files:listing
{{ files:listing }}
Creates a list of files within the specified folder.
Attributes
| Name | Default | Required | Description |
|---|---|---|---|
| folder | None | No | The folder to display files from. Can be an ID (123) or a path (images/blog/kittens). |
| tagged | None | No | Only return images with this tag or tags. You can use this along with the "folder" attribute or by itself to search all files. |
| limit | 10 | No | Maximum number of files to return. |
| offset | No | Skip this many files. Usually used together with limit. | |
| type | No | Only return files of this type. Valid values: a, v, d, i, o. (audio, video, document, image, other) | |
| fetch | None | No | Return the files in the subfolders specified. Separate multiple folders with the pipe character: blog|pages |
| order-by | id | No | Database column to order pages by. |
Image Usage
This example would create a list of thumbnails 200px wide by 150px tall:
{{ files:listing folder="5" }}
<img src="{{ url:site }}files/thumb/{{ id }}/200/150" alt="{{ description }}"/>
{{ /files:listing }}
Available Variables:
{{ id }}
{{ file_id }}
{{ folder_id }}
{{ user_id }}
{{ type }}
{{ name }}
{{ filename }}
{{ description }}
{{ extension }}
{{ mimetype }}
{{ width }}
{{ height }}
{{ filesize }}
{{ date_added }}
Returns:
<img src="http://pyrocms.com/files/thumb/1/200/150" alt="foo description"/>
<img src="http://pyrocms.com/files/thumb/2/200/150" alt="bar description"/>
<img src="http://pyrocms.com/files/thumb/3/200/150" alt="baz description"/>
File Usage
You can could also create a list of file download links:
{{ files:listing folder="5" }}
<a href="{{ url:site }}files/download/{{ id }}">Download {{ name }}</a>
{{ /files:listing }}
Available Variables:
{{ id }}
{{ folder_id }}
{{ user_id }}
{{ type }}
{{ name }}
{{ filename }}
{{ description }}
{{ extension }}
{{ mimetype }}
{{ filesize }}
{{ date_added }}
Returns:
<a href="http://pyrocms.com/files/thumb/1/200/150">Download foo description</a>
<a href="http://pyrocms.com/files/thumb/2/200/150">Download bar description</a>
<a href="http://pyrocms.com/files/thumb/3/200/150">Download baz description</a>
files:folder_exists
{{ files:folder_exists slug="sample_folder" }}
Check if the specified folder really does exist. Returns boolean.
Attributes
| Name | Default | Required | Description |
|---|---|---|---|
| slug | None | Yes | Required. The folder slug to check for. |
files:exists
{{ files:exists id="45" }}
Check if the specified file really does exist. Returns boolean.
Attributes
| Name | Default | Required | Description |
|---|---|---|---|
| id | None | Yes | The file id to check for |
files:path
{{ files:path id="45" }}
Returns the filesystem path to the file.
Attributes
| Name | Default | Required | Description |
|---|---|---|---|
| id | None | Yes | The file id that you want the path for |
files:url
{{ files:url id="45" }}
Returns the url to the file.
Attributes
| Name | Default | Required | Description |
|---|---|---|---|
| id | None | Yes | The file id that you want the URL for |
files:image_path
{{ files:image_path id="45" }}
Returns the filesystem path to the image.
Attributes
| Name | Default | Required | Description |
|---|---|---|---|
| id | None | Yes | Required. The file id of the image. |
files:image_url
{{ files:image_url id="45" }}
Returns the url to the image.
Attributes
| Name | Default | Required | Description |
|---|---|---|---|
| id | None | Yes | The file id of the image |
files:image
{{ files:image id="45" width="100" height="100" mode="fill" }}
Returns an image tag for the specified image.
Attributes
| Name | Default | Required | Description |
|---|---|---|---|
| id | None | Yes | The file id of the image |
| width | 100 | No | For images specify the desired width in pixels for it to be resized to. |
| height | 100 | No | For images specify the desired height in pixels for it to be resized to. |
| size | None | No | For images specify the desired width/height. Shorthand for the width and height attributes above. size="200/150" |
| mode | None | No | The resize mode to use when resizing an image. May be either "fit" or "fill". |
