GWcode FileInfo Examples

Example 1: Get information about a single file

{exp:gwcode_fileinfo:single file="/media/myimage.jpg"}
	{if file_not_found}The file couldn't be found!{/if}
	File full path: {file_fullpath}<br />
	File URL: {file_url}<br />
	File name: {file_name}<br />
	File basename: {file_basename}<br />
	File extension: {file_extension}<br />
	File extension mime: {file_extension_mime}<br />
	File size in bytes: {file_size_bytes}<br />
	File size formatted: {file_size_formatted}<br />
	File symbolic permissions: {file_symbolic_permissions}<br />
	File octal permissions: {file_octal_permissions}<br />
	File is image: {if file_is_image}Yes{if:else}No{/if}<br />
	{if file_is_image}
		Image width: {image_width}<br />
		Image height: {image_height}<br />
		Image bits: {image_bits}<br />
		Image channels: {image_channels}<br />
		Image mime: {image_mime}<br />
	{/if}
{/exp:gwcode_fileinfo:single}

Example 1: Output

File full path: /full/server/path/to/docroot/media/my_image.jpg
File URL: http://domain.tld/media/my_image.jpg
File name: my_image.jpg
File basename: my_image
File extension: jpg
File extension mime: image/jpeg
File size in bytes: 741843
File size formatted: 724.46 KB
File symbolic permissions: -rw-r--r--
File octal permissions: 644
File is image: Yes
Image width: 1345
Image height: 1174
Image bits: 8
Image channels: 3
Image mime: image/jpeg

Example 2: Get information about files in a directory

{exp:gwcode_fileinfo:multiple directory="/path/to/media/"}
	Count: {count}<br />
	Total results: {total_results}<br />
	Switch: {switch="uneven|even"}<br />
	File full path: {file_fullpath}<br />
	File URL: {file_url}<br />
	File name: {file_name}<br />
	File basename: {file_basename}<br />
	File extension: {file_extension}<br />
	File extension mime: {file_extension_mime}<br />
	File size in bytes: {file_size_bytes}<br />
	File size formatted: {file_size_formatted}<br />
	File symbolic permissions: {file_symbolic_permissions}<br />
	File octal permissions: {file_octal_permissions}<br />
	File is image: {if file_is_image}Yes{if:else}No{/if}<br />
	{if file_is_image}
		Image width: {image_width}<br />
		Image height: {image_height}<br />
		Image bits: {image_bits}<br />
		Image channels: {image_channels}<br />
		Image mime: {image_mime}<br />
	{/if}
	<br />
{/exp:gwcode_fileinfo:multiple}

Example 3: Get information about files stored in a matrix field

In this example, {cf_matrix_gallery} is our matrix field and {cf_matrix_gallery_yourmatrixcolumn} is our matrix field column which has the location of the file.

{exp:channel:entries channel="my_channel" limit="1"}
	<h3>{title}</h3>
	<h4>Files stored in our matrix field (cf_matrix_gallery):</h4>
	{cf_matrix_gallery}
		{exp:gwcode_fileinfo:single file="{cf_matrix_gallery_yourmatrixcolumn}"}
			{if file_not_found}The file "{cf_matrix_gallery_yourmatrixcolumn}" could not be found!{/if}
			File full path: {file_fullpath}<br />
			File URL: {file_url}<br />
			File name: {file_name}<br />
			File basename: {file_basename}<br />
			File extension: {file_extension}<br />
			File extension mime: {file_extension_mime}<br />
			File size in bytes: {file_size_bytes}<br />
			File size formatted: {file_size_formatted}<br />
			File symbolic permissions: {file_symbolic_permissions}<br />
			File octal permissions: {file_octal_permissions}<br />
			File is image: {if file_is_image}Yes{if:else}No{/if}<br />
			{if file_is_image}
				Image width: {image_width}<br />
				Image height: {image_height}<br />
				Image bits: {image_bits}<br />
				Image channels: {image_channels}<br />
				Image mime: {image_mime}<br />
			{/if}
		{/exp:gwcode_fileinfo:single}
		<br />
	{/cf_matrix_gallery}
{/exp:channel:entries}