Forum

Thread tagged as: Question

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.

Stuart Farrell

Stuart Farrell 0 points

  • 7 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

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"

Drew McLellan

Drew McLellan 2638 points
Perch Support

Try format="MB"

That's the ticket! Thanks.