GWcode FileInfo

http://gwcode.com/assets/img/add-ons/tn/gwcode-fileinfo.gif

ExpressionEngine plugin to get information about files on your server, such as the file's extension, size, the filename without the extension, file type, the dimensions (if the file is an image), etc.

I've created this plugin when we needed to output the base name (filename but without the extension) of each image in a Matrix gallery, and the filesize. When the project was finished,
I decided to expand the features and realease it as a free plugin.

The plugin provides two tags, one to get information about a single file and one to get information about all files in a directory.
Let's break it down to show what parameters and variables are available for both tags.

{exp:gwcode_fileinfo:single}

Get information about a single file.

Parameters

Parameter Possible Value(s) Example Description
file a path or URL to a file on your server file="my_file.jpg" The single file you'd like to get information for.
variable_prefix anything variable_prefix="gw:" Allows you to add a prefix to all variables used by GWcode FileInfo, to prevent conflicts with another add-on or native ExpressionEngine variables when you nest tags. For example, {file_name} will become {gw:file_name}.

Variables

Variable This will output..
{file_fullpath} The full server path to the file. Example: /full/server/path/to/docroot/media/my_image.jpg
{file_url} The URL to the file. Example: http://domain.tld/media/my_image.jpg
{file_name} The full file name. Example: my_image.jpg
{file_basename} The file's basename (filename without extension). Example: my_image
{file_extension} The file's extension. Example: jpg
{file_extension_mime} The file's extension MIME type, as defined in system/expressionengine/config/mimes.php. Example: image/jpg.
{file_size_bytes} The file's size in bytes. Example: 741843
{file_size_formatted} The file's size, formatted. Example: 724.46 KB.
{file_symbolic_permissions} The file's permissions, formatted. Example: -rw-r--r--
{file_octal_permissions} The file's octal permissions. Example: 644.
{file_is_image} Will be true if the file is an image.
{image_width} The image width in pixels. Example: 1345
{image_height} The image height in pixels. Example: 1174
{image_bits} The number of bits for each color. Example: 8. Click here for more information.
{image_channels} Will be 3 for RGB and 4 for CMYK pictures.
{image_mime} The MIME type of the image. This can be different from {file_extension_mime} when for example image.jpg has been renamed to image.gif. This variable will then output image/jpeg, whereas {file_extension_mime} will output image/gif.

 

{exp:gwcode_fileinfo:multiple}

Get information about files in a directory.

Parameters

Parameter Possible Value(s) Example Description
directory a path or URL to a directory on your server directory="/path/to/directory" The directory that contains the files you'd like to get information for.
variable_prefix anything variable_prefix="gw:" Allows you to add a prefix to all variables used by GWcode FileInfo, to prevent conflicts with another add-on or native ExpressionEngine variables when you nest tags. For example, {file_name} will become {gw:file_name}.

Variables

Besides all variables from the {exp:gwcode_fileinfo:single} tag above, the following additional variables are available for the {exp:gwcode_fileinfo:multiple} tag.

Variable Description
{count} Incrementing number for each file in the output.
{total_results} Total number of files being returned in the output.
{switch} This variable permits you to rotate through any number of values, which you can use to add CSS classes for example. Example: {switch="one|two|three"}

Visit the examples page to see how you use the tags!