How can I access the file extension of an asset? Migrated from a Slack #help channel question



Jason Mayo [09:53 16/6/15]

Is there anyway to output what file type an assets file is? E.g. if its a Jpeg, SVG or Gif etc.
Yes, you can access a number of properties on assets. You can get the "file group" (whether it's a document, image, video etc) using:

{{ asset[0].kind }}

More specifically, you can access the file extension using:

{{ asset[0].extension }}

Full list in the documentation at: http://buildwithcraft.com/docs/templating/assetfilemodel