Forum
Automatically display the size and name of a file uploaded to Assets
Am using a file upload field, and was wondering if we can easily display the file name and file size using a field/file ID in template? There are more complex PHP approaches, but if Perch Assets knows them then surely we can call them yes?
As a note too, would be good to have the info seen in list view also on detail view of items in Asset library, as it's not in the default grid view. (File size, dimensions etc).
Thanks.
You can output the file size with the output attribute
https://docs.grabaperch.com/docs/templates/attributes/type/file/
For images there are additional output options
https://docs.grabaperch.com/docs/templates/attributes/type/image/
OK thanks.
Is there anyway to truncate the bytes display? EG, a 14kb PDF displays as "14159"
Try
format="MB"
That's the ticket! Thanks.